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

Unified Diff: Source/platform/graphics/GraphicsContext.h

Issue 651243002: Clarify GraphicsContext::beginLayer()/endLayer() have unexpected behaviors. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: beginLayer()/endLayer() don't behave like save()/restore() 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
Index: Source/platform/graphics/GraphicsContext.h
diff --git a/Source/platform/graphics/GraphicsContext.h b/Source/platform/graphics/GraphicsContext.h
index 42189353bdfe69e13ce2c54ddf4266a8c248cf2f..adbba90477ea2bd52829fede55cf85628622fe66 100644
--- a/Source/platform/graphics/GraphicsContext.h
+++ b/Source/platform/graphics/GraphicsContext.h
@@ -98,9 +98,6 @@ public:
void disableDestructionChecks() { m_disableDestructionChecks = true; }
#endif
- void saveLayer(const SkRect* bounds, const SkPaint*);
- void restoreLayer();
-
bool hasStroke() const { return strokeStyle() != NoStroke && strokeThickness() > 0; }
float strokeThickness() const { return immutableState()->strokeData().thickness(); }
@@ -326,6 +323,8 @@ public:
void drawLineForDocumentMarker(const FloatPoint&, float width, DocumentMarkerLineStyle);
void beginTransparencyLayer(float opacity, const FloatRect* = 0);
+ // Apply CompositeOperator when the layer is composited on the backdrop (i.e. endLayer()).
+ // Don't change the current CompositeOperator state.
void beginLayer(float opacity, CompositeOperator, const FloatRect* = 0, ColorFilter = ColorFilterNone, ImageFilter* = 0);
void endLayer();
@@ -436,6 +435,9 @@ private:
static void draw2xMarker(SkBitmap*, int);
#endif
+ void saveLayer(const SkRect* bounds, const SkPaint*);
+ void restoreLayer();
dshwang 2014/10/16 15:58:20 go to private:
Justin Novosad 2014/10/16 17:51:58 Good idea
+
// Helpers for drawing a focus ring (drawFocusRing)
float prepareFocusRingPaint(SkPaint&, const Color&, int width) const;
void drawFocusRingPath(const SkPath&, const Color&, int width);
@@ -492,9 +494,14 @@ private:
#if ENABLE(ASSERT)
unsigned m_annotationCount;
- unsigned m_layerCount;
bool m_disableDestructionChecks;
#endif
+ // Keep the top of the clip stack of each layer. It's needed because beginLayer()/endLayer() has the different contract
+ // from SkCanvas::saveLayer()/restore(). When endLayer() calls SkCanvas::restore(), the clip state is restored before beginLayer().
+ // This member is used to re-apply all clip operations after beginLayer(). Important to note that SkCanvas::saveLayer()
+ // may perform an additional clip operation, which prevent endLayer() from getting the stack pointer by itself.
+ Vector<unsigned> m_clipStackPointersOfLayerStack;
+
// Tracks the region painted opaque via the GraphicsContext.
RegionTracker m_trackedRegion;

Powered by Google App Engine
This is Rietveld 408576698