aboutsummaryrefslogtreecommitdiffhomepage
path: root/samplecode/SampleShaderText.cpp
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-06-13 21:55:32 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-06-13 21:55:32 +0000
commit3914958a49ee089ddeb04acc16373aae8bc2eaf7 (patch)
tree86785f882cb8472c819b5123e862fef5e58109f7 /samplecode/SampleShaderText.cpp
parent79d2dbed5a08e0d3f65646d52b4bb884cd0af9b5 (diff)
Fix text-as-path with skshader on gpu
Review URL: http://codereview.appspot.com/4576057/ git-svn-id: http://skia.googlecode.com/svn/trunk@1575 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'samplecode/SampleShaderText.cpp')
-rw-r--r--samplecode/SampleShaderText.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/samplecode/SampleShaderText.cpp b/samplecode/SampleShaderText.cpp
index 2748b559a2..dedf04d72a 100644
--- a/samplecode/SampleShaderText.cpp
+++ b/samplecode/SampleShaderText.cpp
@@ -118,7 +118,7 @@ protected:
virtual void onDrawContent(SkCanvas* canvas) {
const char text[] = "Shaded Text";
const int textLen = SK_ARRAY_COUNT(text) - 1;
- static int pointSize = 48;
+ static int pointSize = 36;
int w = pointSize * textLen;
int h = pointSize;
@@ -166,17 +166,29 @@ protected:
canvas->save();
canvas->translate(SkIntToScalar(20), SkIntToScalar(10));
+ SkPath path;
+ path.arcTo(SkRect::MakeXYWH(-40, 15, 300, 90),
+ SK_Scalar1 * 225, SK_Scalar1 * 90, false);
+ path.close();
+
static const int testsPerCol = 8;
static const int rowHeight = 60;
static const int colWidth = 300;
canvas->save();
for (size_t s = 0; s < SK_ARRAY_COUNT(shaders); s++) {
canvas->save();
- canvas->translate(SkIntToScalar((s / testsPerCol) * colWidth),
- SkIntToScalar((s % testsPerCol) * rowHeight));
+ int i = 2*s;
+ canvas->translate(SkIntToScalar((i / testsPerCol) * colWidth),
+ SkIntToScalar((i % testsPerCol) * rowHeight));
paint.setShader(shaders[s])->unref();
canvas->drawText(text, textLen, 0, textBase, paint);
canvas->restore();
+ canvas->save();
+ ++i;
+ canvas->translate(SkIntToScalar((i / testsPerCol) * colWidth),
+ SkIntToScalar((i % testsPerCol) * rowHeight));
+ canvas->drawTextOnPath(text, textLen, path, NULL, paint);
+ canvas->restore();
}
canvas->restore();