aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/complexclip.cpp
diff options
context:
space:
mode:
authorGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-07-13 14:55:25 +0000
committerGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-07-13 14:55:25 +0000
commit54bb7abc09e06b41aaf3dca633d27ccc7b291bad (patch)
treeb6030c035fc77bedd57d635001277fc3efb28b68 /gm/complexclip.cpp
parentaf07d065d19ec387b783b6dfdc3deafd7c614b69 (diff)
Improved clarity of complexclip GM
Diffstat (limited to 'gm/complexclip.cpp')
-rw-r--r--gm/complexclip.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/gm/complexclip.cpp b/gm/complexclip.cpp
index 3783669b7e..60546126b3 100644
--- a/gm/complexclip.cpp
+++ b/gm/complexclip.cpp
@@ -19,11 +19,11 @@ static const SkColor gClipBColor = SK_ColorRED;
class ComplexClipGM : public GM {
bool fDoAAClip;
- bool fSaveLayer;
+ bool fDoSaveLayer;
public:
ComplexClipGM(bool aaclip, bool saveLayer)
: fDoAAClip(aaclip)
- , fSaveLayer(saveLayer) {
+ , fDoSaveLayer(saveLayer) {
this->setBGColor(0xFFDDDDDD);
// this->setBGColor(SkColorSetRGB(0xB0,0xDD,0xB0));
}
@@ -34,7 +34,7 @@ protected:
SkString str;
str.printf("complexclip_%s%s",
fDoAAClip ? "aa" : "bw",
- fSaveLayer ? "_layer" : "");
+ fDoSaveLayer ? "_layer" : "");
return str;
}
@@ -95,8 +95,17 @@ protected:
canvas->translate(SkIntToScalar(20), SkIntToScalar(20));
canvas->scale(3 * SK_Scalar1 / 4, 3 * SK_Scalar1 / 4);
- if (fSaveLayer) {
- SkRect bounds = SkRect::MakeXYWH(100, 100, 1000, 750);
+ if (fDoSaveLayer) {
+ // We want the layer to appear symmetric relative to actual
+ // device boundaries so we need to "undo" the effect of the
+ // scale and translate
+ SkRect bounds = SkRect::MakeLTRB(
+ SkIntToScalar(4.0f/3.0f * -20),
+ SkIntToScalar(4.0f/3.0f * -20),
+ SkFloatToScalar(4.0f/3.0f * (this->getISize().fWidth - 20)),
+ SkFloatToScalar(4.0f/3.0f * (this->getISize().fHeight - 20)));
+
+ bounds.inset(SkIntToScalar(100), SkIntToScalar(100));
SkPaint boundPaint;
boundPaint.setColor(SK_ColorRED);
boundPaint.setStyle(SkPaint::kStroke_Style);
@@ -144,7 +153,7 @@ protected:
canvas->translate(0, SkIntToScalar(250));
}
- if (fSaveLayer) {
+ if (fDoSaveLayer) {
canvas->restore();
}
}