diff options
author | 2014-10-29 12:36:45 -0700 | |
---|---|---|
committer | 2014-10-29 12:36:45 -0700 | |
commit | 89889b69391a730f0ba2a1efb549864b7762263f (patch) | |
tree | 85e8cb00c41ae79cf4a693491138acd7853b0dfb /samplecode | |
parent | 8f3937d9fcb28018ec14db6697d41b645716d589 (diff) |
MultiPictureDraw is taskgroup aware.
SampleApp is multipicturedraw aware.
BUG=skia:
Review URL: https://codereview.chromium.org/684923002
Diffstat (limited to 'samplecode')
-rw-r--r-- | samplecode/SampleApp.cpp | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp index 2c17379f88..1b4a55e5dd 100644 --- a/samplecode/SampleApp.cpp +++ b/samplecode/SampleApp.cpp @@ -742,6 +742,8 @@ DEFINE_bool(list, false, "List samples?"); 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 @@ SampleWindow::SampleWindow(void* hwnd, int argc, char** argv, DeviceManager* dev fCurrIndex = 0; } + static SkTaskGroup::Enabler enabled(-1); gSampleWindow = this; #ifdef PIPE_FILE @@ -1306,7 +1309,7 @@ SkCanvas* SampleWindow::beforeChildren(SkCanvas* canvas) { return canvas; } - +#include "SkMultiPictureDraw.h" void SampleWindow::afterChildren(SkCanvas* orig) { if (fSaveToPdf) { fSaveToPdf = false; @@ -1336,7 +1339,39 @@ void SampleWindow::afterChildren(SkCanvas* orig) { 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); |