aboutsummaryrefslogtreecommitdiff
path: root/src/core/SkRecordDraw.cpp
diff options
context:
space:
mode:
authorDerek Sollenberger <djsollen@google.com>2019-04-04 11:49:14 -0400
committerMichele Bono <bono.michele94@gmail.com>2019-08-07 16:13:50 +0200
commit55c3d512b95a8b515b7a6a8542da8c0f28270b2e (patch)
treea6098e8aaafb8daeed174c4c9c784c5cb26e6689 /src/core/SkRecordDraw.cpp
parent1f50aa929088085c6a4fa1c6de435193cbde9ee2 (diff)
Add private save-behind and draw-behind methods to canvas.HEADp9.0
The draw-behind is a variant of drawPaint but is automatically clipped to the bounds of the most recent saveBehind buffer (axis-aligned bounds). No public exposure outside of the Android framework. Impl is pretty simple (its a variant of drawPaint) - find the most recent saveBehind device bounds - if there is none, draw nothing, else - temporarily intersect the device's clip with that bounds - drawPaint - restore the clip This patches did not apply cleanly and have been updated to compile with a previous version of Skia. It was cherry-picked from the following 3 Skia commits: 148b7fd3ad9c29dec0052de624c26ff291ef8f0a d567408362bf7847d6000f6786f9a7b2c9d0b88b 9adc82c73df0ef25b708cae8aa48ef9c39ed4c67 Bug: 129117085 Test: None Change-Id: I291f57885de6e95f749bf5cdb70ac16a5781ffb1
Diffstat (limited to 'src/core/SkRecordDraw.cpp')
-rw-r--r--src/core/SkRecordDraw.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/core/SkRecordDraw.cpp b/src/core/SkRecordDraw.cpp
index 89eb8a751a..2d819e6799 100644
--- a/src/core/SkRecordDraw.cpp
+++ b/src/core/SkRecordDraw.cpp
@@ -6,6 +6,7 @@
*/
#include "SkRecordDraw.h"
+#include "SkCanvasPriv.h"
#include "SkImage.h"
#include "SkPatchUtils.h"
@@ -82,6 +83,15 @@ DRAW(SaveLayer, saveLayer(SkCanvas::SaveLayerRec(r.bounds,
r.clipMask.get(),
r.clipMatrix,
r.saveLayerFlags)));
+
+template <> void Draw::draw(const SaveBehind& r) {
+ SkCanvasPriv::SaveBehind(fCanvas, r.subset);
+}
+
+template <> void Draw::draw(const DrawBehind& r) {
+ SkCanvasPriv::DrawBehind(fCanvas, r.paint);
+}
+
DRAW(SetMatrix, setMatrix(SkMatrix::Concat(fInitialCTM, r.matrix)));
DRAW(Concat, concat(r.matrix));
DRAW(Translate, translate(r.dx, r.dy));
@@ -290,6 +300,7 @@ private:
// from the bounds of the ops in the same Save block.
void trackBounds(const Save&) { this->pushSaveBlock(nullptr); }
void trackBounds(const SaveLayer& op) { this->pushSaveBlock(op.paint); }
+ void trackBounds(const SaveBehind&) { this->pushSaveBlock(nullptr); }
void trackBounds(const Restore&) { fBounds[fCurrentOp] = this->popSaveBlock(); }
void trackBounds(const SetMatrix&) { this->pushControl(); }
@@ -396,6 +407,7 @@ private:
Bounds bounds(const DrawText&) const { return fCurrentClipBounds; }
Bounds bounds(const DrawPaint&) const { return fCurrentClipBounds; }
+ Bounds bounds(const DrawBehind&) const { return fCurrentClipBounds; }
Bounds bounds(const NoOp&) const { return Bounds::MakeEmpty(); } // NoOps don't draw.
Bounds bounds(const DrawRect& op) const { return this->adjustAndMap(op.rect, &op.paint); }