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

Unified Diff: samplecode/SampleApp.cpp

Issue 1129603002: add DeferredCanvas mode to SampleApp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 7 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 | « samplecode/SampleApp.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samplecode/SampleApp.cpp
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index 9b5a972ec835346e713a6669b71761db3f8582a7..82d42fdfc45d94ed7d80ec52729ef578f41ad98a 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -15,6 +15,7 @@
#include "SkCanvas.h"
#include "SkCommandLineFlags.h"
#include "SkData.h"
+#include "SkDeferredCanvas.h"
#include "SkDevice.h"
#include "SkDocument.h"
#include "SkGPipe.h"
@@ -181,10 +182,9 @@ public:
#if SK_SUPPORT_GPU
switch (win->getDeviceType()) {
- case kRaster_DeviceType:
- // fallthrough
- case kPicture_DeviceType:
- // fallthrough
+ case kRaster_DeviceType: // fallthrough
+ case kPicture_DeviceType: // fallthrough
+ case kDeferred_DeviceType: // fallthrough
case kGPU_DeviceType:
// all these guys use the native backend
fBackend = kNativeGL_BackEndType;
@@ -210,10 +210,9 @@ public:
SkASSERT(NULL == fCurIntf);
SkAutoTUnref<const GrGLInterface> glInterface;
switch (win->getDeviceType()) {
- case kRaster_DeviceType:
- // fallthrough
- case kPicture_DeviceType:
- // fallthrough
+ case kRaster_DeviceType: // fallthrough
+ case kPicture_DeviceType: // fallthrough
+ case kDeferred_DeviceType: // fallthrough
case kGPU_DeviceType:
// all these guys use the native interface
glInterface.reset(GrGLCreateNativeInterface());
@@ -673,7 +672,8 @@ static inline SampleWindow::DeviceType cycle_devicetype(SampleWindow::DeviceType
SampleWindow::kANGLE_DeviceType,
#endif // SK_ANGLE
#endif // SK_SUPPORT_GPU
- SampleWindow::kRaster_DeviceType
+ SampleWindow::kDeferred_DeviceType,
+ SampleWindow::kRaster_DeviceType,
};
SK_COMPILE_ASSERT(SK_ARRAY_COUNT(gCT) == SampleWindow::kDeviceTypeCnt, array_size_mismatch);
return gCT[ct];
@@ -829,7 +829,7 @@ SampleWindow::SampleWindow(void* hwnd, int argc, char** argv, DeviceManager* dev
int itemID;
itemID =fAppMenu->appendList("Device Type", "Device Type", sinkID, 0,
- "Raster", "Picture", "OpenGL",
+ "Raster", "Picture", "OpenGL", "Deferred",
#if SK_ANGLE
"ANGLE",
#endif
@@ -1196,6 +1196,12 @@ SkCanvas* SampleWindow::beforeChildren(SkCanvas* canvas) {
canvas = fPDFDocument->beginPage(this->width(), this->height());
} else if (kPicture_DeviceType == fDeviceType) {
canvas = fRecorder.beginRecording(9999, 9999, NULL, 0);
+ } else if (kDeferred_DeviceType == fDeviceType) {
+ fDeferredSurface.reset(canvas->newSurface(canvas->imageInfo()));
+ if (fDeferredSurface.get()) {
+ fDeferredCanvas.reset(SkDeferredCanvas::Create(fDeferredSurface));
+ canvas = fDeferredCanvas;
+ }
} else {
canvas = this->INHERITED::beforeChildren(canvas);
}
@@ -1284,6 +1290,13 @@ void SampleWindow::afterChildren(SkCanvas* orig) {
} else {
picture->playback(orig);
}
+ } else if (kDeferred_DeviceType == fDeviceType) {
+ SkAutoTUnref<SkImage> image(fDeferredCanvas->newImageSnapshot());
+ if (image) {
+ orig->drawImage(image, 0, 0, NULL);
+ }
+ fDeferredCanvas.reset(NULL);
+ fDeferredSurface.reset(NULL);
}
// Do this after presentGL and other finishing, rather than in afterChild
@@ -1858,6 +1871,7 @@ static const char* gDeviceTypePrefix[] = {
"angle: ",
#endif // SK_ANGLE
#endif // SK_SUPPORT_GPU
+ "deferred: ",
};
SK_COMPILE_ASSERT(SK_ARRAY_COUNT(gDeviceTypePrefix) == SampleWindow::kDeviceTypeCnt,
array_size_mismatch);
« no previous file with comments | « samplecode/SampleApp.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698