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

Unified Diff: example/HelloWorld.cpp

Issue 2178353005: Remove use of MakeRenderTargetDirect from view system (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix Mac Created 4 years, 5 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 | « example/HelloWorld.h ('k') | include/views/SkWindow.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: example/HelloWorld.cpp
diff --git a/example/HelloWorld.cpp b/example/HelloWorld.cpp
index 32bee5dccd445a81e8724d959b7b7748e6349d63..5239311c85c81b2513b2443af7ac1ccf2e74ee47 100644
--- a/example/HelloWorld.cpp
+++ b/example/HelloWorld.cpp
@@ -29,7 +29,6 @@ void application_term() {
HelloWorldWindow::HelloWorldWindow(void* hwnd)
: INHERITED(hwnd) {
fType = kGPU_DeviceType;
- fRenderTarget = NULL;
fRotationAngle = 0;
this->setTitle();
this->setUpBackend();
@@ -46,8 +45,7 @@ void HelloWorldWindow::tearDownBackend() {
SkSafeUnref(fInterface);
fInterface = NULL;
- SkSafeUnref(fRenderTarget);
- fRenderTarget = NULL;
+ fGpuSurface = nullptr;
INHERITED::release();
}
@@ -70,19 +68,17 @@ bool HelloWorldWindow::setUpBackend() {
}
fInterface = GrGLCreateNativeInterface();
-
SkASSERT(NULL != fInterface);
fContext = GrContext::Create(kOpenGL_GrBackend, (GrBackendContext)fInterface);
SkASSERT(NULL != fContext);
- this->setUpRenderTarget();
+ this->setUpGpuBackedSurface();
return true;
}
-void HelloWorldWindow::setUpRenderTarget() {
- SkSafeUnref(fRenderTarget);
- fRenderTarget = this->renderTarget(fAttachmentInfo, fInterface, fContext);
+void HelloWorldWindow::setUpGpuBackedSurface() {
+ fGpuSurface = this->makeGpuBackedSurface(fAttachmentInfo, fInterface, fContext);
}
void HelloWorldWindow::drawContents(SkCanvas* canvas) {
@@ -142,7 +138,7 @@ void HelloWorldWindow::drawContents(SkCanvas* canvas) {
}
void HelloWorldWindow::draw(SkCanvas* canvas) {
- drawContents(canvas);
+ this->drawContents(canvas);
// in case we have queued drawing calls
fContext->flush();
// Invalidate the window to force a redraw. Poor man's animation mechanism.
@@ -150,21 +146,22 @@ void HelloWorldWindow::draw(SkCanvas* canvas) {
if (kRaster_DeviceType == fType) {
// need to send the raster bits to the (gpu) window
- sk_sp<SkImage> snap = fSurface->makeImageSnapshot();
+ sk_sp<SkImage> snap = fRasterSurface->makeImageSnapshot();
SkPixmap pmap;
if (snap->peekPixels(&pmap)) {
const SkImageInfo& info = pmap.info();
- fRenderTarget->writePixels(0, 0, snap->width(), snap->height(),
- SkImageInfo2GrPixelConfig(info, *fContext->caps()),
- pmap.addr(), pmap.rowBytes(),
- GrContext::kFlushWrites_PixelOp);
+
+ SkCanvas* canvas = fGpuSurface->getCanvas();
+
+ canvas->writePixels(info, pmap.addr(), pmap.rowBytes(), 0, 0);
+ canvas->flush();
}
}
INHERITED::present();
}
void HelloWorldWindow::onSizeChange() {
- setUpRenderTarget();
+ this->setUpGpuBackedSurface();
}
bool HelloWorldWindow::onHandleChar(SkUnichar unichar) {
« no previous file with comments | « example/HelloWorld.h ('k') | include/views/SkWindow.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698