OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/logging.h" | 5 #include "base/logging.h" |
6 #include "base/trace_event/trace_event.h" | 6 #include "base/trace_event/trace_event.h" |
7 #include "skia/ext/analysis_canvas.h" | 7 #include "skia/ext/analysis_canvas.h" |
8 #include "third_party/skia/include/core/SkDraw.h" | 8 #include "third_party/skia/include/core/SkDraw.h" |
9 #include "third_party/skia/include/core/SkRRect.h" | 9 #include "third_party/skia/include/core/SkRRect.h" |
10 #include "third_party/skia/include/core/SkShader.h" | 10 #include "third_party/skia/include/core/SkShader.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 xfermode == SkXfermode::kSrcOver_Mode)); | 53 xfermode == SkXfermode::kSrcOver_Mode)); |
54 } | 54 } |
55 | 55 |
56 // Returns true if the specified drawn_rect will cover the entire canvas, and | 56 // Returns true if the specified drawn_rect will cover the entire canvas, and |
57 // that the canvas is not clipped (i.e. it covers ALL of the canvas). | 57 // that the canvas is not clipped (i.e. it covers ALL of the canvas). |
58 bool IsFullQuad(SkCanvas* canvas, const SkRect& drawn_rect) { | 58 bool IsFullQuad(SkCanvas* canvas, const SkRect& drawn_rect) { |
59 if (!canvas->isClipRect()) | 59 if (!canvas->isClipRect()) |
60 return false; | 60 return false; |
61 | 61 |
62 SkIRect clip_irect; | 62 SkIRect clip_irect; |
63 canvas->getClipDeviceBounds(&clip_irect); | 63 if (!canvas->getClipDeviceBounds(&clip_irect)) |
| 64 return false; |
| 65 |
64 // if the clip is smaller than the canvas, we're partly clipped, so abort. | 66 // if the clip is smaller than the canvas, we're partly clipped, so abort. |
65 if (!clip_irect.contains(SkIRect::MakeSize(canvas->getDeviceSize()))) | 67 if (!clip_irect.contains(SkIRect::MakeSize(canvas->getDeviceSize()))) |
66 return false; | 68 return false; |
67 | 69 |
68 const SkMatrix& matrix = canvas->getTotalMatrix(); | 70 const SkMatrix& matrix = canvas->getTotalMatrix(); |
69 // If the transform results in a non-axis aligned | 71 // If the transform results in a non-axis aligned |
70 // rect, then be conservative and return false. | 72 // rect, then be conservative and return false. |
71 if (!matrix.rectStaysRect()) | 73 if (!matrix.rectStaysRect()) |
72 return false; | 74 return false; |
73 | 75 |
(...skipping 15 matching lines...) Expand all Loading... |
89 } | 91 } |
90 | 92 |
91 void AnalysisCanvas::SetForceNotTransparent(bool flag) { | 93 void AnalysisCanvas::SetForceNotTransparent(bool flag) { |
92 is_forced_not_transparent_ = flag; | 94 is_forced_not_transparent_ = flag; |
93 if (is_forced_not_transparent_) | 95 if (is_forced_not_transparent_) |
94 is_transparent_ = false; | 96 is_transparent_ = false; |
95 } | 97 } |
96 | 98 |
97 void AnalysisCanvas::onDrawPaint(const SkPaint& paint) { | 99 void AnalysisCanvas::onDrawPaint(const SkPaint& paint) { |
98 SkRect rect; | 100 SkRect rect; |
99 getClipBounds(&rect); | 101 if (getClipBounds(&rect)) |
100 drawRect(rect, paint); | 102 drawRect(rect, paint); |
101 } | 103 } |
102 | 104 |
103 void AnalysisCanvas::onDrawPoints(SkCanvas::PointMode mode, | 105 void AnalysisCanvas::onDrawPoints(SkCanvas::PointMode mode, |
104 size_t count, | 106 size_t count, |
105 const SkPoint points[], | 107 const SkPoint points[], |
106 const SkPaint& paint) { | 108 const SkPaint& paint) { |
107 is_solid_color_ = false; | 109 is_solid_color_ = false; |
108 is_transparent_ = false; | 110 is_transparent_ = false; |
109 ++draw_op_count_; | 111 ++draw_op_count_; |
110 } | 112 } |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 force_not_transparent_stack_level_ = kNoLayer; | 446 force_not_transparent_stack_level_ = kNoLayer; |
445 } | 447 } |
446 } | 448 } |
447 | 449 |
448 INHERITED::willRestore(); | 450 INHERITED::willRestore(); |
449 } | 451 } |
450 | 452 |
451 } // namespace skia | 453 } // namespace skia |
452 | 454 |
453 | 455 |
OLD | NEW |