Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / skia / ext / analysis_canvas.cc
index cb61607..ca19170 100644 (file)
@@ -110,8 +110,14 @@ void AnalysisCanvas::drawPoints(SkCanvas::PointMode mode,
 }
 
 void AnalysisCanvas::drawRect(const SkRect& rect, const SkPaint& paint) {
-  // This recreates the early-exit logic in SkCanvas.cpp, which aborts early
-  // if the paint will "draw nothing".
+  // This recreates the early-exit logic in SkCanvas.cpp.
+  SkRect scratch;
+  if (paint.canComputeFastBounds() &&
+      quickReject(paint.computeFastBounds(rect, &scratch))) {
+    return;
+  }
+
+  // An extra no-op check SkCanvas.cpp doesn't do.
   if (paint.nothingToDraw())
     return;
 
@@ -261,6 +267,15 @@ void AnalysisCanvas::onDrawTextOnPath(const void* text,
   ++draw_op_count_;
 }
 
+void AnalysisCanvas::onDrawTextBlob(const SkTextBlob* blob,
+                                    SkScalar x,
+                                    SkScalar y,
+                                    const SkPaint &paint) {
+  is_solid_color_ = false;
+  is_transparent_ = false;
+  ++draw_op_count_;
+}
+
 void AnalysisCanvas::onDrawDRRect(const SkRRect& outer,
                                   const SkRRect& inner,
                                   const SkPaint& paint) {
@@ -299,8 +314,10 @@ AnalysisCanvas::AnalysisCanvas(int width, int height)
       is_forced_not_solid_(false),
       is_forced_not_transparent_(false),
       is_solid_color_(true),
+      color_(SK_ColorTRANSPARENT),
       is_transparent_(true),
-      draw_op_count_(0) {}
+      draw_op_count_(0) {
+}
 
 AnalysisCanvas::~AnalysisCanvas() {}
 
@@ -331,15 +348,8 @@ bool AnalysisCanvas::abortDrawing() {
   return false;
 }
 
-void AnalysisCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, 
-                                ClipEdgeStyle edge_style) {
-
-  INHERITED::onClipRect(rect, op, edge_style);
-}
-
-void AnalysisCanvas::onClipPath(const SkPath& path, SkRegion::Op op,
-                                ClipEdgeStyle edge_style) {
-  // clipPaths can make our calls to IsFullQuad invalid (ie have false
+void AnalysisCanvas::OnComplexClip() {
+  // complex clips can make our calls to IsFullQuad invalid (ie have false
   // positives). As a precaution, force the setting to be non-solid
   // and non-transparent until we pop this
   if (force_not_solid_stack_level_ == kNoLayer) {
@@ -350,28 +360,39 @@ void AnalysisCanvas::onClipPath(const SkPath& path, SkRegion::Op op,
     force_not_transparent_stack_level_ = saved_stack_size_;
     SetForceNotTransparent(true);
   }
+}
+
+void AnalysisCanvas::onClipRect(const SkRect& rect,
+                                SkRegion::Op op,
+                                ClipEdgeStyle edge_style) {
+  INHERITED::onClipRect(rect, op, edge_style);
+}
 
+void AnalysisCanvas::onClipPath(const SkPath& path,
+                                SkRegion::Op op,
+                                ClipEdgeStyle edge_style) {
+  OnComplexClip();
   INHERITED::onClipRect(path.getBounds(), op, edge_style);
 }
 
 void AnalysisCanvas::onClipRRect(const SkRRect& rrect,
                                  SkRegion::Op op,
                                  ClipEdgeStyle edge_style) {
-  // clipRRect can make our calls to IsFullQuad invalid (ie have false
-  // positives). As a precaution, force the setting to be non-solid
-  // and non-transparent until we pop this
-  if (force_not_solid_stack_level_ == kNoLayer) {
-    force_not_solid_stack_level_ = saved_stack_size_;
-    SetForceNotSolid(true);
-  }
-  if (force_not_transparent_stack_level_ == kNoLayer) {
-    force_not_transparent_stack_level_ = saved_stack_size_;
-    SetForceNotTransparent(true);
-  }
-
+  OnComplexClip();
   INHERITED::onClipRect(rrect.getBounds(), op, edge_style);
 }
 
+void AnalysisCanvas::onClipRegion(const SkRegion& deviceRgn, SkRegion::Op op) {
+  const ClipEdgeStyle edge_style = kHard_ClipEdgeStyle;
+  if (deviceRgn.isRect()) {
+    onClipRect(SkRect::MakeFromIRect(deviceRgn.getBounds()), op, edge_style);
+    return;
+  }
+  OnComplexClip();
+  INHERITED::onClipRect(
+      SkRect::MakeFromIRect(deviceRgn.getBounds()), op, edge_style);
+}
+
 void AnalysisCanvas::willSave() {
   ++saved_stack_size_;
   INHERITED::willSave();