Improved clarity of complexclip GM

http://codereview.appspot.com/6344108/



git-svn-id: http://skia.googlecode.com/svn/trunk@4596 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gm/complexclip.cpp b/gm/complexclip.cpp
index 3783669..6054612 100644
--- a/gm/complexclip.cpp
+++ b/gm/complexclip.cpp
@@ -19,11 +19,11 @@
 
 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 @@
         SkString str;
         str.printf("complexclip_%s%s", 
                    fDoAAClip ? "aa" : "bw",
-                   fSaveLayer ? "_layer" : "");
+                   fDoSaveLayer ? "_layer" : "");
         return str;
     }
 
@@ -95,8 +95,17 @@
         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 @@
             canvas->translate(0, SkIntToScalar(250));
         }
 
-        if (fSaveLayer) {
+        if (fDoSaveLayer) {
             canvas->restore();
         }
     }