MultiPictureDraw is taskgroup aware.
SampleApp is multipicturedraw aware.
BUG=skia:
Review URL: https://codereview.chromium.org/684923002
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index 2c17379..1b4a55e 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -742,6 +742,8 @@
DEFINE_string(pdfPath, "", "Path to direcotry of pdf files.");
#endif
+#include "SkTaskGroup.h"
+
SampleWindow::SampleWindow(void* hwnd, int argc, char** argv, DeviceManager* devManager)
: INHERITED(hwnd)
, fDevManager(NULL) {
@@ -813,6 +815,7 @@
fCurrIndex = 0;
}
+ static SkTaskGroup::Enabler enabled(-1);
gSampleWindow = this;
#ifdef PIPE_FILE
@@ -1306,7 +1309,7 @@
return canvas;
}
-
+#include "SkMultiPictureDraw.h"
void SampleWindow::afterChildren(SkCanvas* orig) {
if (fSaveToPdf) {
fSaveToPdf = false;
@@ -1336,7 +1339,39 @@
if (true) {
this->installDrawFilter(orig);
- orig->drawPicture(picture);
+
+ if (true) {
+ SkImageInfo info;
+ size_t rowBytes;
+ void* addr = orig->accessTopLayerPixels(&info, &rowBytes);
+ if (addr) {
+ SkSurface* surfs[4];
+ SkMultiPictureDraw md;
+
+ SkImageInfo n = SkImageInfo::Make(info.width()/2, info.height()/2,
+ info.colorType(), info.alphaType());
+ int index = 0;
+ for (int y = 0; y < 2; ++y) {
+ for (int x = 0; x < 2; ++x) {
+ char* p = (char*)addr;
+ p += y * n.height() * rowBytes;
+ p += x * n.width() * sizeof(SkPMColor);
+ surfs[index] = SkSurface::NewRasterDirect(n, p, rowBytes);
+ SkCanvas* c = surfs[index]->getCanvas();
+ c->translate(SkIntToScalar(-x * n.width()),
+ SkIntToScalar(-y * n.height()));
+ md.add(c, picture, NULL, NULL);
+ index++;
+ }
+ }
+ md.draw();
+ for (int i = 0; i < 4; ++i) {
+ surfs[i]->unref();
+ }
+ }
+ } else {
+ orig->drawPicture(picture);
+ }
} else if (true) {
SkDynamicMemoryWStream ostream;
picture->serialize(&ostream);