From 399be5bf559f72d4649a60320a3d802f6b21780b Mon Sep 17 00:00:00 2001 From: Cary Clark Date: Mon, 14 Mar 2016 16:51:29 -0400 Subject: Add bitmaps and skp output to Skia port This is a first-cut at supporting bitmaps. Also added a --skp option to pdfium_test to generate a Skia picture file. The picture file can be loaded in Skia's SampleApp, debugger, or skiaserver to examine the generated picture. (This also includes fixes suggested in the prior Skia CL. My apologies for fat-fingers abandoning that one.) R=dsinclair@chromium.org, tsepez@chromium.org, dsinclair Review URL: https://codereview.chromium.org/1776313002 . --- fpdfsdk/fpdfview.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'fpdfsdk/fpdfview.cpp') diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp index 48fe0664a2..4630ac1e7e 100644 --- a/fpdfsdk/fpdfview.cpp +++ b/fpdfsdk/fpdfview.cpp @@ -645,7 +645,7 @@ DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap, CRenderContext* pContext = new CRenderContext; pPage->SetPrivateData((void*)1, pContext, DropContext); #ifdef _SKIA_SUPPORT_ - pContext->m_pDevice = new CFX_SkiaDevice; + pContext->m_pDevice = new CFX_SkiaDevice(); if (flags & FPDF_REVERSE_BYTE_ORDER) ((CFX_SkiaDevice*)pContext->m_pDevice) @@ -669,6 +669,26 @@ DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap, pPage->RemovePrivateData((void*)1); } +#ifdef _SKIA_SUPPORT_ +DLLEXPORT FPDF_RECORDER STDCALL FPDF_RenderPageSkp(FPDF_PAGE page, + int size_x, + int size_y) { + CPDF_Page* pPage = CPDFPageFromFPDFPage(page); + if (!pPage) + return nullptr; + std::unique_ptr pContext(new CRenderContext); + pPage->SetPrivateData((void*)1, pContext.get(), DropContext); + CFX_SkiaDevice* skDevice = new CFX_SkiaDevice(); + FPDF_RECORDER recorder = skDevice->CreateRecorder(size_x, size_y); + pContext->m_pDevice = skDevice; + + FPDF_RenderPage_Retail(pContext.get(), page, 0, 0, size_x, size_y, 0, 0, TRUE, + NULL); + pPage->RemovePrivateData((void*)1); + return recorder; +} +#endif + DLLEXPORT void STDCALL FPDF_ClosePage(FPDF_PAGE page) { if (!page) return; -- cgit v1.2.3