#include "SkCanvas.h"
#include "SkCommandLineFlags.h"
#include "SkData.h"
+#include "SkDeferredCanvas.h"
#include "SkDevice.h"
#include "SkDocument.h"
#include "SkGPipe.h"
#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;
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());
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];
int itemID;
itemID =fAppMenu->appendList("Device Type", "Device Type", sinkID, 0,
- "Raster", "Picture", "OpenGL",
+ "Raster", "Picture", "OpenGL", "Deferred",
#if SK_ANGLE
"ANGLE",
#endif
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);
}
} 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
"angle: ",
#endif // SK_ANGLE
#endif // SK_SUPPORT_GPU
+ "deferred: ",
};
SK_COMPILE_ASSERT(SK_ARRAY_COUNT(gDeviceTypePrefix) == SampleWindow::kDeviceTypeCnt,
array_size_mismatch);