From 4ea96c5e5449248780acfeb3cef4ec812f955d74 Mon Sep 17 00:00:00 2001 From: "keyar@chromium.org" Date: Mon, 20 Aug 2012 15:03:29 +0000 Subject: Dirty commit so Brian can see changes. git-svn-id: http://skia.googlecode.com/svn/trunk@5171 2bbb7eff-a529-9590-31e7-b0007b416f81 --- gyp/tools.gyp | 2 ++ tools/PictureRenderer.cpp | 36 +++++++++++++++++++++++++++++++++--- tools/PictureRenderer.h | 22 +++++++++++++++++++++- tools/render_pictures_main.cpp | 2 ++ 4 files changed, 58 insertions(+), 4 deletions(-) diff --git a/gyp/tools.gyp b/gyp/tools.gyp index 3910b703f0..799c96074c 100644 --- a/gyp/tools.gyp +++ b/gyp/tools.gyp @@ -129,6 +129,8 @@ ], 'dependencies': [ 'core.gyp:core', + 'gpu.gyp:gr', + 'gpu.gyp:skgr', 'tools.gyp:picture_utils', ], }, diff --git a/tools/PictureRenderer.cpp b/tools/PictureRenderer.cpp index f0aba9fc6a..e9e14de923 100644 --- a/tools/PictureRenderer.cpp +++ b/tools/PictureRenderer.cpp @@ -8,6 +8,13 @@ #include "SkTypes.h" #include "picture_utils.h" +#if SK_SUPPORT_GPU +#include "gl/GrGLInterface.h" +#include "GrContext.h" +#include "SkGpuDevice.h" +#include "GrContextFactory.h" +#endif + namespace sk_tools { enum { @@ -28,9 +35,32 @@ void PictureRenderer::init(SkPicture* pict) { } fPicture = pict; - SkBitmap bitmap; - sk_tools::setup_bitmap(&bitmap, fPicture->width(), fPicture->height()); - fCanvas.reset(SkNEW_ARGS(SkCanvas, (bitmap))); + switch(fDeviceType) { + case kBitmap_DeviceType: { + SkBitmap bitmap; + sk_tools::setup_bitmap(&bitmap, fPicture->width(), fPicture->height()); + fCanvas.reset(SkNEW_ARGS(SkCanvas, (bitmap))); + break; + } +#if SK_SUPPORT_GPU + case kGPU_DeviceType: { +// const GrGLInterface* interface = GrGLCreateNativeInterface(); +// GrContext* context = GrContext::Create(kOpenGL_Shaders_GrEngine, +// (GrPlatform3DContext) interface); + fGLContext = new SkNativeGLContext(); + SkASSERT(fGLContext->init(pict->width(), pict->height())); + GrContextFactory factory; + GrContext* context = factory.get(GrContextFactory::kNative_GLContextType); + SkAutoTUnref device(SkNEW_ARGS(SkGpuDevice, + (context, SkBitmap::kARGB_8888_Config, + pict->width(), pict->height()))); + fCanvas.reset(SkNEW_ARGS(SkCanvas, (device.get()))); + break; + } +#endif + default: + SkASSERT(0); + } } void PictureRenderer::end() { diff --git a/tools/PictureRenderer.h b/tools/PictureRenderer.h index f9b4c260ef..a8975bffa6 100644 --- a/tools/PictureRenderer.h +++ b/tools/PictureRenderer.h @@ -13,6 +13,7 @@ class SkBitmap; class SkCanvas; +class SkGLContext; class SkPicture; namespace sk_tools { @@ -27,10 +28,29 @@ public: return fCanvas.get(); } - PictureRenderer() : fPicture(NULL){} + void setUseBitmapDevice() { + fDeviceType=kBitmap_DeviceType; + } + +#if SK_SUPPORT_GPU + void setUseGpuDevice() { + fDeviceType = kGPU_DeviceType; + } +#endif + + PictureRenderer() : fPicture(NULL), fDeviceType(kBitmap_DeviceType){} protected: + enum SkDeviceTypes { + kBitmap_DeviceType, +#if SK_SUPPORT_GPU + kGPU_DeviceType +#endif + }; + SkAutoTUnref fCanvas; SkPicture* fPicture; + SkDeviceTypes fDeviceType; + SkGLContext* fGLContext; private: typedef SkRefCnt INHERITED; diff --git a/tools/render_pictures_main.cpp b/tools/render_pictures_main.cpp index 86de9bacf0..e1a1eff6eb 100644 --- a/tools/render_pictures_main.cpp +++ b/tools/render_pictures_main.cpp @@ -220,6 +220,8 @@ static void parse_commandline(int argc, char* const argv[], SkTArray* if (NULL == renderer) { renderer = SkNEW(sk_tools::SimplePictureRenderer); } + + renderer->setUseGpuDevice(); } int main(int argc, char* const argv[]) { -- cgit v1.2.3