Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Unified Diff: experimental/PdfViewer/pdf_viewer_main.cpp

Issue 579733003: Revert "Move SkGpuDevice.h to src/gpu" (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | gyp/gpu.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: experimental/PdfViewer/pdf_viewer_main.cpp
diff --git a/experimental/PdfViewer/pdf_viewer_main.cpp b/experimental/PdfViewer/pdf_viewer_main.cpp
index f5bfdbbd7e35eeef353dcc9702eb0df455f9f208..fab3dc01dfd1928e29b1d989a2091747a0e0e2f0 100644
--- a/experimental/PdfViewer/pdf_viewer_main.cpp
+++ b/experimental/PdfViewer/pdf_viewer_main.cpp
@@ -21,6 +21,12 @@
#include "SkTArray.h"
#include "SkNulCanvas.h"
+#if SK_SUPPORT_GPU
+#include "GrContextFactory.h"
+#include "GrContext.h"
+#include "SkGpuDevice.h"
+#endif
+
DEFINE_string2(readPath, r, "", "pdf files or directories of pdf files to process.");
DEFINE_string2(writePath, w, "", "Directory to write the rendered pages.");
DEFINE_bool2(noExtensionForOnePagePdf, n, false, "No page extension if only one page.");
@@ -36,10 +42,18 @@ DEFINE_double(DPI, 72, "DPI to be used for rendering (scale).");
DEFINE_int32(benchLoad, 0, "Load the pdf file minimally N times, without any rendering and \n"
"\tminimal parsing to ensure correctness. Default 0 (disabled).");
DEFINE_int32(benchRender, 0, "Render the pdf content N times. Default 0 (disabled)");
+#if SK_SUPPORT_GPU
DEFINE_string2(config, c, "8888", "Canvas to render:\n"
"\t8888 - argb\n"
+ "\tgpu: use the gpu\n"
"\tnul - render in null canvas, any draw will just return.\n"
);
+#else
+DEFINE_string2(config, c, "8888", "Canvas to render:\n"
+ "\t8888 - argb\n"
+ "\tnul - render in null canvas, any draw will just return.\n"
+ );
+#endif
DEFINE_bool2(transparentBackground, t, false, "Make background transparent instead of white.");
/**
@@ -112,6 +126,10 @@ extern "C" SkBitmap* gDumpBitmap;
extern "C" SkCanvas* gDumpCanvas;
#endif
+#if SK_SUPPORT_GPU
+GrContextFactory gContextFactory;
+#endif
+
static bool render_page(const SkString& outputDir,
const SkString& inputFilename,
const SkPdfRenderer& renderer,
@@ -146,7 +164,31 @@ static bool render_page(const SkString& outputDir,
SkAutoTUnref<SkBaseDevice> device;
if (strcmp(FLAGS_config[0], "8888") == 0) {
device.reset(SkNEW_ARGS(SkBitmapDevice, (bitmap)));
- } else {
+ }
+#if SK_SUPPORT_GPU
+ else if (strcmp(FLAGS_config[0], "gpu") == 0) {
+ SkAutoTUnref<GrSurface> target;
+ GrContext* gr = gContextFactory.get(GrContextFactory::kNative_GLContextType,
+ kNone_GrGLStandard);
+ if (gr) {
+ // create a render target to back the device
+ GrTextureDesc desc;
+ desc.fConfig = kSkia8888_GrPixelConfig;
+ desc.fFlags = kRenderTarget_GrTextureFlagBit;
+ desc.fWidth = SkScalarCeilToInt(width);
+ desc.fHeight = SkScalarCeilToInt(height);
+ desc.fSampleCnt = 0;
+ target.reset(gr->createUncachedTexture(desc, NULL, 0));
+ }
+ if (NULL == target.get()) {
+ SkASSERT(0);
+ return false;
+ }
+
+ device.reset(SkGpuDevice::Create(target));
+ }
+#endif
+ else {
SkDebugf("unknown --config: %s\n", FLAGS_config[0]);
return false;
}
« no previous file with comments | « no previous file | gyp/gpu.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698