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

Unified Diff: src/core/SkMultiPictureDraw.cpp

Issue 533673002: Expose layer hoisting API in GrContext (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix No GPU build 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 | « no previous file | src/gpu/GrLayerHoister.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkMultiPictureDraw.cpp
diff --git a/src/core/SkMultiPictureDraw.cpp b/src/core/SkMultiPictureDraw.cpp
index eb1e55e5508a749d3908111cc2748c0929137ba8..19b26ca60775e1b03d89cfd34952a936254525d2 100644
--- a/src/core/SkMultiPictureDraw.cpp
+++ b/src/core/SkMultiPictureDraw.cpp
@@ -5,6 +5,11 @@
* found in the LICENSE file.
*/
+#if SK_SUPPORT_GPU
+#include "GrLayerHoister.h"
+#include "GrRecordReplaceDraw.h"
+#endif
+
#include "SkCanvas.h"
#include "SkMultiPictureDraw.h"
#include "SkPicture.h"
@@ -50,12 +55,66 @@ void SkMultiPictureDraw::add(SkCanvas* canvas,
}
}
+#undef SK_IGNORE_GPU_LAYER_HOISTING
+#define SK_IGNORE_GPU_LAYER_HOISTING 1
+
void SkMultiPictureDraw::draw() {
+
+#ifndef SK_IGNORE_GPU_LAYER_HOISTING
+ GrContext* context = NULL;
+
+ SkTDArray<GrHoistedLayer> atlased, nonAtlased, recycled;
+
for (int i = 0; i < fDrawData.count(); ++i) {
- fDrawData[i].canvas->drawPicture(fDrawData[i].picture,
- &fDrawData[i].matrix,
- fDrawData[i].paint);
+ if (fDrawData[i].canvas->getGrContext() &&
+ !fDrawData[i].paint && fDrawData[i].matrix.isIdentity()) {
+ SkASSERT(NULL == context || context == fDrawData[i].canvas->getGrContext());
+ context = fDrawData[i].canvas->getGrContext();
+
+ // TODO: this path always tries to optimize pictures. Should we
+ // switch to this API approach (vs. SkCanvas::EXPERIMENTAL_optimize)?
+ fDrawData[i].canvas->EXPERIMENTAL_optimize(fDrawData[i].picture);
+
+ SkRect clipBounds;
+ if (!fDrawData[i].canvas->getClipBounds(&clipBounds)) {
+ continue;
+ }
+
+ GrLayerHoister::FindLayersToHoist(context, fDrawData[i].picture,
+ clipBounds, &atlased, &nonAtlased, &recycled);
+ }
+ }
+
+ GrReplacements replacements;
+
+ if (NULL != context) {
+ GrLayerHoister::DrawLayers(atlased, nonAtlased, recycled, &replacements);
+ }
+#endif
+
+ for (int i = 0; i < fDrawData.count(); ++i) {
+#ifndef SK_IGNORE_GPU_LAYER_HOISTING
+ if (fDrawData[i].canvas->getGrContext() &&
+ !fDrawData[i].paint && fDrawData[i].matrix.isIdentity()) {
+ // Render the entire picture using new layers
+ const SkMatrix initialMatrix = fDrawData[i].canvas->getTotalMatrix();
+
+ GrRecordReplaceDraw(fDrawData[i].picture, fDrawData[i].canvas,
+ &replacements, initialMatrix, NULL);
+ } else
+#endif
+ {
+ fDrawData[i].canvas->drawPicture(fDrawData[i].picture,
+ &fDrawData[i].matrix,
+ fDrawData[i].paint);
+ }
+ }
+
+#ifndef SK_IGNORE_GPU_LAYER_HOISTING
+ if (NULL != context) {
+ GrLayerHoister::UnlockLayers(context, atlased, nonAtlased, recycled);
}
+#endif
this->reset();
}
« no previous file with comments | « no previous file | src/gpu/GrLayerHoister.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698