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); |