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

Unified Diff: experimental/SkV8Example/SkV8Example.cpp

Issue 148523019: Move SkV8Example to SkSurface (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: review comments 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..96b52725d5530d351283f0d34aa475789141f1a0 100644
--- a/experimental/SkV8Example/SkV8Example.cpp
+++ b/experimental/SkV8Example/SkV8Example.cpp
@@ -27,6 +27,7 @@ using namespace v8;
#include "SkGpuDevice.h"
#include "SkGraphics.h"
#include "SkScalar.h"
+#include "SkSurface.h"
DEFINE_string2(infile, i, NULL, "Name of file to load JS from.\n");
@@ -49,9 +50,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);
@@ -60,6 +62,15 @@ SkV8ExampleWindow::SkV8ExampleWindow(void* hwnd, JsContext* context)
#endif
}
+SkV8ExampleWindow::~SkV8ExampleWindow() {
+#if SK_SUPPORT_GPU
+ SkSafeUnref(fCurContext);
+ SkSafeUnref(fCurIntf);
+ SkSafeUnref(fCurRenderTarget);
+ SkSafeUnref(fCurSurface);
+#endif
+}
+
#if SK_SUPPORT_GPU
void SkV8ExampleWindow::windowSizeChanged() {
if (FLAGS_gpu) {
@@ -92,6 +103,8 @@ void SkV8ExampleWindow::windowSizeChanged() {
SkSafeUnref(fCurRenderTarget);
fCurRenderTarget = fCurContext->wrapBackendRenderTarget(desc);
+ SkSafeUnref(fCurSurface);
+ fCurSurface = SkSurface::NewRenderTargetDirect(fCurRenderTarget);
}
}
#endif
@@ -99,9 +112,12 @@ void SkV8ExampleWindow::windowSizeChanged() {
#if SK_SUPPORT_GPU
SkCanvas* SkV8ExampleWindow::createCanvas() {
if (FLAGS_gpu) {
- SkAutoTUnref<SkBaseDevice> device(
- new SkGpuDevice(fCurContext, fCurRenderTarget));
- return new SkCanvas(device);
+ SkCanvas* c = 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