Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2081)

Unified Diff: experimental/SkV8Example/SkV8Example.cpp

Issue 148523019: Move SkV8Example to SkSurface (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix gpu refcount for canvas held by surface. Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « experimental/SkV8Example/SkV8Example.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
}
« no previous file with comments | « experimental/SkV8Example/SkV8Example.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698