#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 {
}
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() {
class SkBitmap;
class SkCanvas;
+class SkGLContext;
class SkPicture;
namespace sk_tools {
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;