diff options
author | borenet <borenet@google.com> | 2014-09-17 06:14:35 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-17 06:14:35 -0700 |
commit | b0a35f7c5d2c4bfeb601e3ac43f412d202a25292 (patch) | |
tree | dbca8fcf788889950be5e08ac69c828d0a2b262d | |
parent | e3371304b8c06a29aa3581c8decd9046c712c5f6 (diff) |
Revert "Move SkGpuDevice.h to src/gpu"
This reverts commit d99bbb61e58e8bd34db3954147ce1c9166fe4637.
Causing Chrome canary failures as well as failures of Chrome trybots due to
not cleaning up properly after failed DEPS roll attempts.
BUG=skia:
R=bsalomon@google.com, reed@google.com
TBR=bsalomon, reed
Author: borenet@google.com
Review URL: https://codereview.chromium.org/579733003
-rw-r--r-- | experimental/PdfViewer/pdf_viewer_main.cpp | 44 | ||||
-rw-r--r-- | gyp/gpu.gypi | 2 | ||||
-rw-r--r-- | include/gpu/SkGpuDevice.h (renamed from src/gpu/SkGpuDevice.h) | 0 |
3 files changed, 44 insertions, 2 deletions
diff --git a/experimental/PdfViewer/pdf_viewer_main.cpp b/experimental/PdfViewer/pdf_viewer_main.cpp index f5bfdbbd7e..fab3dc01df 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; } diff --git a/gyp/gpu.gypi b/gyp/gpu.gypi index a6af660643..693d1f3915 100644 --- a/gyp/gpu.gypi +++ b/gyp/gpu.gypi @@ -269,6 +269,7 @@ '<(skia_src_path)/gpu/gl/builders/GrGLGeometryShaderBuilder.h', # Sk files + '<(skia_include_path)/gpu/SkGpuDevice.h', '<(skia_include_path)/gpu/SkGr.h', '<(skia_include_path)/gpu/SkGrPixelRef.h', '<(skia_include_path)/gpu/SkGrTexturePixelRef.h', @@ -276,7 +277,6 @@ '<(skia_include_path)/gpu/gl/SkGLContextHelper.h', '<(skia_src_path)/gpu/SkGpuDevice.cpp', - '<(skia_src_path)/gpu/SkGpuDevice.h', '<(skia_src_path)/gpu/SkGr.cpp', '<(skia_src_path)/gpu/SkGrPixelRef.cpp', '<(skia_src_path)/gpu/SkGrTexturePixelRef.cpp', diff --git a/src/gpu/SkGpuDevice.h b/include/gpu/SkGpuDevice.h index 419013f4ae..419013f4ae 100644 --- a/src/gpu/SkGpuDevice.h +++ b/include/gpu/SkGpuDevice.h |