call through to the device from SkDraw
authorreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Wed, 5 Jun 2013 18:00:30 +0000 (18:00 +0000)
committerreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Wed, 5 Jun 2013 18:00:30 +0000 (18:00 +0000)
BUG=
R=robertphillips@google.com

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

git-svn-id: http://skia.googlecode.com/svn/trunk@9449 2bbb7eff-a529-9590-31e7-b0007b416f81

gm/bigtext.cpp [new file with mode: 0644]
gyp/gmslides.gypi
src/core/SkDraw.cpp

diff --git a/gm/bigtext.cpp b/gm/bigtext.cpp
new file mode 100644 (file)
index 0000000..e8bddf8
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2013 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "gm.h"
+#include "SkCanvas.h"
+#include "SkPath.h"
+
+/**
+ *  Skia may draw from outlines when the size is very large, so we exercise that
+ *  here.
+*/
+
+class BigTextGM : public skiagm::GM {
+public:
+    BigTextGM() {}
+
+protected:
+    virtual SkString onShortName() SK_OVERRIDE {
+        return SkString("bigtext");
+    }
+
+    virtual SkISize onISize() SK_OVERRIDE {
+        return SkISize::Make(640, 480);
+    }
+
+    virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+        SkPaint paint;
+        paint.setAntiAlias(true);
+        paint.setTextSize(1500);
+
+        SkRect r;
+        (void)paint.measureText("/", 1, &r);
+        SkPoint pos = {
+            this->width()/2 - r.centerX(),
+            this->height()/2 - r.centerY()
+        };
+
+        paint.setColor(SK_ColorRED);
+        canvas->drawText("/", 1, pos.fX, pos.fY, paint);
+        
+        paint.setColor(SK_ColorBLUE);
+        canvas->drawPosText("\\", 1, &pos, paint);
+    }
+
+private:
+    typedef skiagm::GM INHERITED;
+};
+
+DEF_GM( return SkNEW(BigTextGM); )
index c67c2d1dad88e48961eb56aeb305ae4aca3d3522..632a2757ce159d3f25e7d7ac776e9226f5ba1bde 100644 (file)
@@ -7,6 +7,7 @@
     '../gm/arithmode.cpp',
     '../gm/bicubicfilter.cpp',
     '../gm/bigmatrix.cpp',
+    '../gm/bigtext.cpp',
     '../gm/bitmapcopy.cpp',
     '../gm/bitmapmatrix.cpp',
     '../gm/bitmapfilters.cpp',
index 5782fc537eb25f31f06068c61f7d8270a6dd314c..30d5956ae839e6a39ee622bc823fda91a3e0215c 100644 (file)
@@ -1861,12 +1861,8 @@ void SkDraw::drawPosText_asPaths(const char text[], size_t byteLength,
     SkPaint paint(origPaint);
     SkScalar matrixScale = paint.setupForAsPaths();
 
-    SkDraw draw(*this);
-
-    // Now modify our matrix to account for the canonical text size
-    SkMatrix matrix = *fMatrix;
-    matrix.preScale(matrixScale, matrixScale);
-    const SkScalar posScale = SkScalarInvert(matrixScale);
+    SkMatrix matrix;
+    matrix.setScale(matrixScale, matrixScale);
 
     SkDrawCacheProc     glyphCacheProc = paint.getDrawCacheProc();
     SkAutoGlyphCache    autoCache(paint, NULL, NULL);
@@ -1886,11 +1882,13 @@ void SkDraw::drawPosText_asPaths(const char text[], size_t byteLength,
                 SkIPoint fixedLoc;
                 alignProc(tms.fLoc, glyph, &fixedLoc);
 
-                SkMatrix localMatrix = matrix;
-                localMatrix.preTranslate(SkFixedToScalar(fixedLoc.fX) * posScale,
-                                         SkFixedToScalar(fixedLoc.fY) * posScale);
-                draw.fMatrix = &localMatrix;
-                draw.drawPath(*path, paint);
+                matrix[SkMatrix::kMTransX] = SkFixedToScalar(fixedLoc.fX);
+                matrix[SkMatrix::kMTransY] = SkFixedToScalar(fixedLoc.fY);
+                if (fDevice) {
+                    fDevice->drawPath(*this, *path, paint, &matrix, false);
+                } else {
+                    this->drawPath(*path, paint, &matrix, false);
+                }
             }
         }
         pos += scalarsPerPosition;