Commit 59b165d9 authored by hendrikw@chromium.org's avatar hendrikw@chromium.org

AnalysisCanvas is missing an override for virtual void onClipRegion

BUG=405364

Review URL: https://codereview.chromium.org/492943002

Cr-Commit-Position: refs/heads/master@{#291548}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@291548 0039d316-1c4b-4281-b951-d872f2087c98
parent cf2b255e
...@@ -331,15 +331,8 @@ bool AnalysisCanvas::abortDrawing() { ...@@ -331,15 +331,8 @@ bool AnalysisCanvas::abortDrawing() {
return false; return false;
} }
void AnalysisCanvas::onClipRect(const SkRect& rect, SkRegion::Op op, void AnalysisCanvas::OnComplexClip() {
ClipEdgeStyle edge_style) { // complex clips can make our calls to IsFullQuad invalid (ie have false
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
// positives). As a precaution, force the setting to be non-solid // positives). As a precaution, force the setting to be non-solid
// and non-transparent until we pop this // and non-transparent until we pop this
if (force_not_solid_stack_level_ == kNoLayer) { if (force_not_solid_stack_level_ == kNoLayer) {
...@@ -350,28 +343,39 @@ void AnalysisCanvas::onClipPath(const SkPath& path, SkRegion::Op op, ...@@ -350,28 +343,39 @@ void AnalysisCanvas::onClipPath(const SkPath& path, SkRegion::Op op,
force_not_transparent_stack_level_ = saved_stack_size_; force_not_transparent_stack_level_ = saved_stack_size_;
SetForceNotTransparent(true); 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); INHERITED::onClipRect(path.getBounds(), op, edge_style);
} }
void AnalysisCanvas::onClipRRect(const SkRRect& rrect, void AnalysisCanvas::onClipRRect(const SkRRect& rrect,
SkRegion::Op op, SkRegion::Op op,
ClipEdgeStyle edge_style) { ClipEdgeStyle edge_style) {
// clipRRect can make our calls to IsFullQuad invalid (ie have false OnComplexClip();
// 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);
}
INHERITED::onClipRect(rrect.getBounds(), op, edge_style); 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() { void AnalysisCanvas::willSave() {
++saved_stack_size_; ++saved_stack_size_;
INHERITED::willSave(); INHERITED::willSave();
......
...@@ -84,6 +84,8 @@ class SK_API AnalysisCanvas : public SkCanvas, public SkDrawPictureCallback { ...@@ -84,6 +84,8 @@ class SK_API AnalysisCanvas : public SkCanvas, public SkDrawPictureCallback {
virtual void onClipPath(const SkPath& path, virtual void onClipPath(const SkPath& path,
SkRegion::Op op, SkRegion::Op op,
ClipEdgeStyle edge_style) OVERRIDE; ClipEdgeStyle edge_style) OVERRIDE;
virtual void onClipRegion(const SkRegion& deviceRgn,
SkRegion::Op op) OVERRIDE;
virtual void onDrawText(const void* text, virtual void onDrawText(const void* text,
size_t byteLength, size_t byteLength,
...@@ -108,7 +110,9 @@ class SK_API AnalysisCanvas : public SkCanvas, public SkDrawPictureCallback { ...@@ -108,7 +110,9 @@ class SK_API AnalysisCanvas : public SkCanvas, public SkDrawPictureCallback {
const SkRRect& inner, const SkRRect& inner,
const SkPaint&) OVERRIDE; const SkPaint&) OVERRIDE;
private: void OnComplexClip();
private:
typedef SkCanvas INHERITED; typedef SkCanvas INHERITED;
int saved_stack_size_; int saved_stack_size_;
......
...@@ -322,4 +322,35 @@ TEST(AnalysisCanvasTest, EarlyOutNotSolid) { ...@@ -322,4 +322,35 @@ TEST(AnalysisCanvasTest, EarlyOutNotSolid) {
} }
TEST(AnalysisCanvasTest, ClipComplexRegion) {
skia::AnalysisCanvas canvas(255, 255);
SkPath path;
path.moveTo(0, 0);
path.lineTo(128, 50);
path.lineTo(255, 0);
path.lineTo(255, 255);
path.lineTo(0, 255);
SkIRect pathBounds = path.getBounds().round();
SkRegion region;
region.setPath(path, SkRegion(pathBounds));
SkColor outputColor;
SolidColorFill(canvas);
canvas.clipRegion(region);
EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor));
canvas.save();
EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor));
canvas.clipRegion(region);
EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor));
canvas.restore();
EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor));
SolidColorFill(canvas);
EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor));
}
} // namespace skia } // namespace skia
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment