diff options
| author | Derek Sollenberger <djsollen@google.com> | 2019-04-04 11:49:14 -0400 |
|---|---|---|
| committer | Michele Bono <bono.michele94@gmail.com> | 2019-08-07 16:13:50 +0200 |
| commit | 55c3d512b95a8b515b7a6a8542da8c0f28270b2e (patch) | |
| tree | a6098e8aaafb8daeed174c4c9c784c5cb26e6689 /src/utils | |
| parent | 1f50aa929088085c6a4fa1c6de435193cbde9ee2 (diff) | |
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/utils')
| -rw-r--r-- | src/utils/SkLuaCanvas.cpp | 5 | ||||
| -rw-r--r-- | src/utils/SkNWayCanvas.cpp | 19 | ||||
| -rw-r--r-- | src/utils/SkPaintFilterCanvas.cpp | 7 |
3 files changed, 31 insertions, 0 deletions
diff --git a/src/utils/SkLuaCanvas.cpp b/src/utils/SkLuaCanvas.cpp index 53e462af0d..aa8aba254c 100644 --- a/src/utils/SkLuaCanvas.cpp +++ b/src/utils/SkLuaCanvas.cpp @@ -100,6 +100,11 @@ SkCanvas::SaveLayerStrategy SkLuaCanvas::getSaveLayerStrategy(const SaveLayerRec return kNoLayer_SaveLayerStrategy; } +bool SkLuaCanvas::onDoSaveBehind(const SkRect*) { + // TODO + return false; +} + void SkLuaCanvas::willRestore() { AUTO_LUA("restore"); this->INHERITED::willRestore(); diff --git a/src/utils/SkNWayCanvas.cpp b/src/utils/SkNWayCanvas.cpp index c612c7d7e1..687413d765 100644 --- a/src/utils/SkNWayCanvas.cpp +++ b/src/utils/SkNWayCanvas.cpp @@ -4,7 +4,9 @@ * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ + #include "SkNWayCanvas.h" +#include "SkCanvasPriv.h" SkNWayCanvas::SkNWayCanvas(int width, int height) : INHERITED(width, height) {} @@ -45,6 +47,7 @@ public: return false; } SkCanvas* operator->() { return fCanvas; } + SkCanvas* get() const { return fCanvas; } private: const SkTDArray<SkCanvas*>& fList; @@ -72,6 +75,15 @@ SkCanvas::SaveLayerStrategy SkNWayCanvas::getSaveLayerStrategy(const SaveLayerRe return kNoLayer_SaveLayerStrategy; } +bool SkNWayCanvas::onDoSaveBehind(const SkRect* bounds) { + Iter iter(fList); + while (iter.next()) { + SkCanvasPriv::SaveBehind(iter.get(), bounds); + } + this->INHERITED::onDoSaveBehind(bounds); + return false; +} + void SkNWayCanvas::willRestore() { Iter iter(fList); while (iter.next()) { @@ -135,6 +147,13 @@ void SkNWayCanvas::onDrawPaint(const SkPaint& paint) { } } +void SkNWayCanvas::onDrawBehind(const SkPaint& paint) { + Iter iter(fList); + while (iter.next()) { + SkCanvasPriv::DrawBehind(iter.get(), paint); + } +} + void SkNWayCanvas::onDrawPoints(PointMode mode, size_t count, const SkPoint pts[], const SkPaint& paint) { Iter iter(fList); diff --git a/src/utils/SkPaintFilterCanvas.cpp b/src/utils/SkPaintFilterCanvas.cpp index 668ebe37a9..7ea95b7845 100644 --- a/src/utils/SkPaintFilterCanvas.cpp +++ b/src/utils/SkPaintFilterCanvas.cpp @@ -48,6 +48,13 @@ void SkPaintFilterCanvas::onDrawPaint(const SkPaint& paint) { } } +void SkPaintFilterCanvas::onDrawBehind(const SkPaint& paint) { + AutoPaintFilter apf(this, kPaint_Type, paint); + if (apf.shouldDraw()) { + this->SkNWayCanvas::onDrawBehind(*apf.paint()); + } +} + void SkPaintFilterCanvas::onDrawPoints(PointMode mode, size_t count, const SkPoint pts[], const SkPaint& paint) { AutoPaintFilter apf(this, kPoint_Type, paint); |
