Index: experimental/SkV8Example/SkV8Example.cpp |
diff --git a/experimental/SkV8Example/SkV8Example.cpp b/experimental/SkV8Example/SkV8Example.cpp |
index eb0e7133769eec94198d58352b8b36509a0968d1..30bc2420cb4ec06bd992bcaeda089a2443fd094f 100644 |
--- a/experimental/SkV8Example/SkV8Example.cpp |
+++ b/experimental/SkV8Example/SkV8Example.cpp |
@@ -26,7 +26,9 @@ using namespace v8; |
#include "SkDraw.h" |
#include "SkGpuDevice.h" |
#include "SkGraphics.h" |
robertphillips
2014/02/26 23:51:08
Is this #include for the kBGRA_8888_SkColorType de
jcgregorio
2014/02/27 14:23:16
I added it for that reason, looks like it isn't ne
|
+#include "SkImageInfo.h" |
#include "SkScalar.h" |
+#include "SkSurface.h" |
DEFINE_string2(infile, i, NULL, "Name of file to load JS from.\n"); |
@@ -49,9 +51,10 @@ SkV8ExampleWindow::SkV8ExampleWindow(void* hwnd, JsContext* context) |
, fCurContext(NULL) |
, fCurIntf(NULL) |
, fCurRenderTarget(NULL) |
+ , fCurSurface(NULL) |
#endif |
{ |
- this->setConfig(SkBitmap::kARGB_8888_Config); |
+ this->setColorType(kBGRA_8888_SkColorType); |
this->setVisibleP(true); |
this->setClipToBounds(false); |
@@ -92,6 +95,8 @@ void SkV8ExampleWindow::windowSizeChanged() { |
SkSafeUnref(fCurRenderTarget); |
fCurRenderTarget = fCurContext->wrapBackendRenderTarget(desc); |
+ SkSafeUnref(fCurSurface); |
robertphillips
2014/02/26 23:51:08
Doesn't this need to get cleaned up in the destruc
jcgregorio
2014/02/27 14:23:16
Added SkSafeUnref's for all the GPU related object
|
+ fCurSurface = SkSurface::NewRenderTargetDirect(fCurRenderTarget); |
} |
} |
#endif |
@@ -99,9 +104,12 @@ void SkV8ExampleWindow::windowSizeChanged() { |
#if SK_SUPPORT_GPU |
robertphillips
2014/02/26 23:51:08
So does the base class not support creating a GPU
jcgregorio
2014/02/27 14:23:16
No, the base class impl is merely new SkCanvas(thi
|
SkCanvas* SkV8ExampleWindow::createCanvas() { |
if (FLAGS_gpu) { |
- SkAutoTUnref<SkBaseDevice> device( |
- new SkGpuDevice(fCurContext, fCurRenderTarget)); |
- return new SkCanvas(device); |
+ SkCanvas* c = fCurSurface->getCanvas(); |
robertphillips
2014/02/26 23:51:08
How isn't there an unbalanced ref problem here? Is
jcgregorio
2014/02/27 14:23:16
Yeah, I would expect that fCurSurface->getCanvas()
|
+ // Increase the ref count since the surface keeps a reference |
+ // to the canvas, but callers of createCanvas put the results |
+ // in a SkAutoTUnref. |
+ c->ref(); |
+ return c; |
} else { |
return this->INHERITED::createCanvas(); |
} |