Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Unified Diff: samplecode/SampleClipDrawMatch.cpp

Issue 890433003: Revert of Add device space "nudge" to gpu draws (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/core/SkClipStack.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samplecode/SampleClipDrawMatch.cpp
diff --git a/samplecode/SampleClipDrawMatch.cpp b/samplecode/SampleClipDrawMatch.cpp
index f897b7185ee5b820058582ee8e6225a8abf219ec..8e2fb46dc9e7ddce4f2aec3ccb55c566e2e304be 100644
--- a/samplecode/SampleClipDrawMatch.cpp
+++ b/samplecode/SampleClipDrawMatch.cpp
@@ -16,7 +16,6 @@
// fractionally (via an animator) to expose snapping bugs. The key bindings are:
// 1-9: the different geometries
// t: toggle which is drawn first the clip or the normal geometry
-// f: flip-flops which corner the bottom AA clip rect occupies in the complex clip cases
// The possible geometric combinations to test
enum Geometry {
@@ -36,10 +35,6 @@
static const float kMid = 200.0f;
static const float kMax = 299.5f;
-// The translation applied to the base AA rect in the combination cases
-// (i.e., kRectAndRect through kRectAndConcave)
-static const float kXlate = 100.0f;
-
SkRect create_rect(const SkPoint& offset) {
SkRect r = SkRect::MakeLTRB(kMin, kMin, kMax, kMax);
r.offset(offset);
@@ -84,6 +79,62 @@
return concavePath;
}
+static void draw_clipped_geom(SkCanvas* canvas, const SkPoint& offset, int geom, bool useAA) {
+
+ int count = canvas->save();
+
+ switch (geom) {
+ case kRect_Geometry:
+ canvas->clipRect(create_rect(offset), SkRegion::kReplace_Op, useAA);
+ break;
+ case kRRect_Geometry:
+ canvas->clipRRect(create_rrect(offset), SkRegion::kReplace_Op, useAA);
+ break;
+ case kCircle_Geometry:
+ canvas->clipRRect(create_circle(offset), SkRegion::kReplace_Op, useAA);
+ break;
+ case kConvexPath_Geometry:
+ canvas->clipPath(create_convex_path(offset), SkRegion::kReplace_Op, useAA);
+ break;
+ case kConcavePath_Geometry:
+ canvas->clipPath(create_concave_path(offset), SkRegion::kReplace_Op, useAA);
+ break;
+ case kRectAndRect_Geometry: {
+ SkRect r = create_rect(offset);
+ r.offset(-100.0f, -100.0f);
+ canvas->clipRect(r, SkRegion::kReplace_Op, true); // AA here forces shader clips
+ canvas->clipRect(create_rect(offset), SkRegion::kIntersect_Op, useAA);
+ } break;
+ case kRectAndRRect_Geometry: {
+ SkRect r = create_rect(offset);
+ r.offset(-100.0f, -100.0f);
+ canvas->clipRect(r, SkRegion::kReplace_Op, true); // AA here forces shader clips
+ canvas->clipRRect(create_rrect(offset), SkRegion::kIntersect_Op, useAA);
+ } break;
+ case kRectAndConvex_Geometry: {
+ SkRect r = create_rect(offset);
+ r.offset(-100.0f, -100.0f);
+ canvas->clipRect(r, SkRegion::kReplace_Op, true); // AA here forces shader clips
+ canvas->clipPath(create_convex_path(offset), SkRegion::kIntersect_Op, useAA);
+ } break;
+ case kRectAndConcave_Geometry: {
+ SkRect r = create_rect(offset);
+ r.offset(-100.0f, -100.0f);
+ canvas->clipRect(r, SkRegion::kReplace_Op, true); // AA here forces shader clips
+ canvas->clipPath(create_concave_path(offset), SkRegion::kIntersect_Op, useAA);
+ } break;
+ }
+
+ SkISize size = canvas->getDeviceSize();
+ SkRect bigR = SkRect::MakeWH(SkIntToScalar(size.width()), SkIntToScalar(size.height()));
+
+ SkPaint p;
+ p.setColor(SK_ColorRED);
+
+ canvas->drawRect(bigR, p);
+ canvas->restoreToCount(count);
+}
+
static void draw_normal_geom(SkCanvas* canvas, const SkPoint& offset, int geom, bool useAA) {
SkPaint p;
p.setAntiAlias(useAA);
@@ -114,7 +165,7 @@
class ClipDrawMatchView : public SampleView {
public:
- ClipDrawMatchView() : fTrans(2, 5), fGeom(kRect_Geometry), fClipFirst(true), fSign(1) {
+ ClipDrawMatchView() : fTrans(2, 5), fGeom(kRect_Geometry), fClipFirst(true) {
SkScalar values[2];
fTrans.setRepeatCount(999);
@@ -148,68 +199,11 @@
case '7': fGeom = kRectAndRRect_Geometry; this->inval(NULL); return true;
case '8': fGeom = kRectAndConvex_Geometry; this->inval(NULL); return true;
case '9': fGeom = kRectAndConcave_Geometry; this->inval(NULL); return true;
- case 'f': fSign = -fSign; this->inval(NULL); return true;
case 't': fClipFirst = !fClipFirst; this->inval(NULL); return true;
default: break;
}
}
return this->INHERITED::onQuery(evt);
- }
-
- void drawClippedGeom(SkCanvas* canvas, const SkPoint& offset, bool useAA) {
-
- int count = canvas->save();
-
- switch (fGeom) {
- case kRect_Geometry:
- canvas->clipRect(create_rect(offset), SkRegion::kReplace_Op, useAA);
- break;
- case kRRect_Geometry:
- canvas->clipRRect(create_rrect(offset), SkRegion::kReplace_Op, useAA);
- break;
- case kCircle_Geometry:
- canvas->clipRRect(create_circle(offset), SkRegion::kReplace_Op, useAA);
- break;
- case kConvexPath_Geometry:
- canvas->clipPath(create_convex_path(offset), SkRegion::kReplace_Op, useAA);
- break;
- case kConcavePath_Geometry:
- canvas->clipPath(create_concave_path(offset), SkRegion::kReplace_Op, useAA);
- break;
- case kRectAndRect_Geometry: {
- SkRect r = create_rect(offset);
- r.offset(fSign * kXlate, fSign * kXlate);
- canvas->clipRect(r, SkRegion::kReplace_Op, true); // AA here forces shader clips
- canvas->clipRect(create_rect(offset), SkRegion::kIntersect_Op, useAA);
- } break;
- case kRectAndRRect_Geometry: {
- SkRect r = create_rect(offset);
- r.offset(fSign * kXlate, fSign * kXlate);
- canvas->clipRect(r, SkRegion::kReplace_Op, true); // AA here forces shader clips
- canvas->clipRRect(create_rrect(offset), SkRegion::kIntersect_Op, useAA);
- } break;
- case kRectAndConvex_Geometry: {
- SkRect r = create_rect(offset);
- r.offset(fSign * kXlate, fSign * kXlate);
- canvas->clipRect(r, SkRegion::kReplace_Op, true); // AA here forces shader clips
- canvas->clipPath(create_convex_path(offset), SkRegion::kIntersect_Op, useAA);
- } break;
- case kRectAndConcave_Geometry: {
- SkRect r = create_rect(offset);
- r.offset(fSign * kXlate, fSign * kXlate);
- canvas->clipRect(r, SkRegion::kReplace_Op, true); // AA here forces shader clips
- canvas->clipPath(create_concave_path(offset), SkRegion::kIntersect_Op, useAA);
- } break;
- }
-
- SkISize size = canvas->getDeviceSize();
- SkRect bigR = SkRect::MakeWH(SkIntToScalar(size.width()), SkIntToScalar(size.height()));
-
- SkPaint p;
- p.setColor(SK_ColorRED);
-
- canvas->drawRect(bigR, p);
- canvas->restoreToCount(count);
}
// Draw a big red rect through some clip geometry and also draw that same
@@ -217,13 +211,13 @@
// This tests whether the clip and normally drawn geometry match up.
void drawGeometry(SkCanvas* canvas, const SkPoint& offset, bool useAA) {
if (fClipFirst) {
- this->drawClippedGeom(canvas, offset, useAA);
+ draw_clipped_geom(canvas, offset, fGeom, useAA);
}
draw_normal_geom(canvas, offset, fGeom, useAA);
if (!fClipFirst) {
- this->drawClippedGeom(canvas, offset, useAA);
+ draw_clipped_geom(canvas, offset, fGeom, useAA);
}
}
@@ -245,7 +239,6 @@
SkInterpolator fTrans;
Geometry fGeom;
bool fClipFirst;
- int fSign;
typedef SampleView INHERITED;
};
« no previous file with comments | « no previous file | src/core/SkClipStack.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698