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

Unified Diff: samplecode/SampleApp.cpp

Issue 684923002: MultiPictureDraw is taskgroup aware. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: actually call Reset() to free the data in each data Created 6 years, 2 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 | « include/core/SkMultiPictureDraw.h ('k') | src/core/SkMultiPictureDraw.cpp » ('j') | 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 2c17379f8803d4081036b22011d896e845a6bcb9..1b4a55e5dd0a88d93d6fc730e9223d20e9c6528d 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);
« no previous file with comments | « include/core/SkMultiPictureDraw.h ('k') | src/core/SkMultiPictureDraw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698