aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar keyar@chromium.org <keyar@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-08-20 15:03:29 +0000
committerGravatar keyar@chromium.org <keyar@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-08-20 15:03:29 +0000
commit4ea96c5e5449248780acfeb3cef4ec812f955d74 (patch)
tree23d2c6e92e629f157bb572f888627634fa5f085b
parentf1369ce607adf55ffffe58fb93893bafb6ff6ebe (diff)
Dirty commit so Brian can see changes.
git-svn-id: http://skia.googlecode.com/svn/trunk@5171 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--gyp/tools.gyp2
-rw-r--r--tools/PictureRenderer.cpp36
-rw-r--r--tools/PictureRenderer.h22
-rw-r--r--tools/render_pictures_main.cpp2
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<SkGpuDevice> 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<SkCanvas> 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<SkString>*
if (NULL == renderer) {
renderer = SkNEW(sk_tools::SimplePictureRenderer);
}
+
+ renderer->setUseGpuDevice();
}
int main(int argc, char* const argv[]) {