}
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;
++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) {
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() {}
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) {
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();