Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / platform / graphics / GraphicsContext.h
index e1ea64f..8896ba3 100644 (file)
@@ -82,20 +82,8 @@ public:
 
     ~GraphicsContext();
 
-    // Returns the canvas used for painting. Must not be called if painting is disabled.
-    // Accessing the backing canvas this way flushes all queued save ops,
-    // so it should be avoided. Use the corresponding draw/matrix/clip methods instead.
-    SkCanvas* canvas()
-    {
-        // Flush any pending saves.
-        realizeCanvasSave();
-
-        return m_canvas;
-    }
-    const SkCanvas* canvas() const
-    {
-        return m_canvas;
-    }
+    SkCanvas* canvas() { return m_canvas; }
+    const SkCanvas* canvas() const { return m_canvas; }
 
     void resetCanvas(SkCanvas*);
 
@@ -104,14 +92,12 @@ public:
     // ---------- State management methods -----------------
     void save();
     void restore();
-    unsigned saveCount() { return m_canvasStateStack.size(); }
+
 #if ENABLE(ASSERT)
+    unsigned saveCount() const;
     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(); }
@@ -251,7 +237,8 @@ public:
     // stroke color).
     void drawRect(const IntRect&);
     void drawLine(const IntPoint&, const IntPoint&);
-    void drawConvexPolygon(size_t numPoints, const FloatPoint*, bool shouldAntialias = false);
+
+    void fillPolygon(size_t numPoints, const FloatPoint*, const Color&, bool shouldAntialias);
 
     void fillPath(const Path&);
     void strokePath(const Path&);
@@ -275,6 +262,8 @@ public:
     void fillBetweenRoundedRects(const RoundedRect&, const RoundedRect&, const Color&);
 
     void drawDisplayList(DisplayList*);
+    void drawPicture(SkPicture*, const FloatPoint& location);
+    void drawPicture(SkPicture*, const FloatRect& dest, const FloatRect& src, CompositeOperator, WebBlendMode);
 
     void drawImage(Image*, const IntPoint&, CompositeOperator = CompositeSourceOver, RespectImageOrientationEnum = DoNotRespectImageOrientation);
     void drawImage(Image*, const IntRect&, CompositeOperator = CompositeSourceOver, RespectImageOrientationEnum = DoNotRespectImageOrientation);
@@ -290,12 +279,9 @@ public:
 
     void drawImageBuffer(ImageBuffer*, const FloatRect& destRect, const FloatRect* srcRect = 0, CompositeOperator = CompositeSourceOver, WebBlendMode = WebBlendModeNormal);
 
-    void drawPicture(PassRefPtr<SkPicture>, const FloatRect& dest, const FloatRect& src, CompositeOperator, WebBlendMode);
-
     // These methods write to the canvas and modify the opaque region, if tracked.
     // Also drawLine(const IntPoint& point1, const IntPoint& point2) and fillRoundedRect
     void writePixels(const SkImageInfo&, const void* pixels, size_t rowBytes, int x, int y);
-    void writePixels(const SkBitmap&, int x, int y);
     void drawBitmap(const SkBitmap&, SkScalar, SkScalar, const SkPaint* = 0);
     void drawBitmapRect(const SkBitmap&, const SkRect*, const SkRect&, const SkPaint* = 0);
     void drawOval(const SkRect&, const SkPaint&);
@@ -317,12 +303,12 @@ public:
     void clipOut(const Path&);
     void clipOutRoundedRect(const RoundedRect&);
     void clipPath(const Path&, WindRule = RULE_EVENODD);
-    void clipConvexPolygon(size_t numPoints, const FloatPoint*, bool antialias = true);
+    void clipPolygon(size_t numPoints, const FloatPoint*, bool antialias);
     void clipRect(const SkRect&, AntiAliasingMode = NotAntiAliased, SkRegion::Op = SkRegion::kIntersect_Op);
     // This clip function is used only by <canvas> code. It allows
     // implementations to handle clipping on the canvas differently since
     // the discipline is different.
-    void canvasClip(const Path&, WindRule = RULE_EVENODD);
+    void canvasClip(const Path&, WindRule = RULE_EVENODD, AntiAliasingMode = NotAntiAliased);
 
     void drawText(const Font&, const TextRunPaintInfo&, const FloatPoint&);
     void drawEmphasisMarks(const Font&, const TextRunPaintInfo&, const AtomicString& mark, const FloatPoint&);
@@ -336,7 +322,10 @@ public:
     };
     void drawLineForDocumentMarker(const FloatPoint&, float width, DocumentMarkerLineStyle);
 
+    // beginLayer()/endLayer() behaves like save()/restore() for only CTM and clip states.
     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();
 
@@ -352,8 +341,8 @@ public:
     bool hasShadow() const;
     void setShadow(const FloatSize& offset, float blur, const Color&,
         DrawLooperBuilder::ShadowTransformMode = DrawLooperBuilder::ShadowRespectsTransforms,
-        DrawLooperBuilder::ShadowAlphaMode = DrawLooperBuilder::ShadowRespectsAlpha);
-    void clearShadow() { clearDrawLooper(); }
+        DrawLooperBuilder::ShadowAlphaMode = DrawLooperBuilder::ShadowRespectsAlpha, ShadowMode = DrawShadowAndForeground);
+    void clearShadow() { clearDrawLooper(); clearDropShadowImageFilter(); }
 
     // It is assumed that this draw looper is used only for shadows
     // (i.e. a draw looper is set if and only if there is a shadow).
@@ -412,6 +401,7 @@ public:
         const SkRect& destRect,
         CompositeOperator,
         WebBlendMode,
+        bool isBitmapWithAlpha,
         bool isLazyDecoded = false,
         bool isDataComplete = true) const;
 
@@ -429,7 +419,7 @@ private:
         return m_paintState;
     }
 
-    static void setPathFromConvexPoints(SkPath*, size_t, const FloatPoint*);
+    static void setPathFromPoints(SkPath*, size_t, const FloatPoint*);
     static void setRadii(SkVector*, IntSize, IntSize, IntSize, IntSize);
 
     static PassRefPtr<SkColorFilter> WebCoreColorFilterToSkiaColorFilter(ColorFilter);
@@ -447,6 +437,9 @@ private:
     static void draw2xMarker(SkBitmap*, int);
 #endif
 
+    void saveLayer(const SkRect* bounds, const SkPaint*);
+    void restoreLayer();
+
     // Helpers for drawing a focus ring (drawFocusRing)
     float prepareFocusRingPaint(SkPaint&, const Color&, int width) const;
     void drawFocusRingPath(const SkPath&, const Color&, int width);
@@ -458,6 +451,10 @@ private:
     void concat(const SkMatrix&);
     void drawRRect(const SkRRect&, const SkPaint&);
 
+    void setDropShadowImageFilter(PassRefPtr<SkImageFilter>);
+    void clearDropShadowImageFilter();
+    SkImageFilter* dropShadowImageFilter() const { return immutableState()->dropShadowImageFilter(); }
+
     // Apply deferred paint state saves
     void realizePaintSave()
     {
@@ -478,17 +475,6 @@ private:
         }
     }
 
-    // Apply deferred canvas state saves
-    void realizeCanvasSave()
-    {
-        if (!m_pendingCanvasSave || contextDisabled())
-            return;
-
-        ASSERT(m_canvas); // m_pendingCanvasSave should never be true when no canvas.
-        m_canvas->save();
-        m_pendingCanvasSave = false;
-    }
-
     void didDrawTextInRect(const SkRect& textRect);
 
     void fillRectWithRoundedHole(const IntRect&, const RoundedRect& roundedHoleRect, const Color&);
@@ -507,13 +493,6 @@ private:
     // Raw pointer to the current state.
     GraphicsContextState* m_paintState;
 
-    // Currently pending save flags for Skia Canvas state.
-    // Canvas state includes the canavs, it's matrix and clips. Think of it as _where_
-    // the draw operations will happen.
-    struct CanvasSaveState;
-    Vector<CanvasSaveState> m_canvasStateStack;
-    bool m_pendingCanvasSave;
-
     AnnotationModeFlags m_annotationMode;
 
     struct RecordingState;
@@ -536,13 +515,13 @@ private:
 
     // Activation for the above region tracking features
     unsigned m_regionTrackingMode : 2;
-    bool m_trackTextRegion : 1;
+    unsigned m_trackTextRegion : 1;
 
-    bool m_accelerated : 1;
-    bool m_isCertainlyOpaque : 1;
-    bool m_printing : 1;
-    bool m_antialiasHairlineImages : 1;
-    bool m_shouldSmoothFonts : 1;
+    unsigned m_accelerated : 1;
+    unsigned m_isCertainlyOpaque : 1;
+    unsigned m_printing : 1;
+    unsigned m_antialiasHairlineImages : 1;
+    unsigned m_shouldSmoothFonts : 1;
 };
 
 } // namespace blink