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

Unified Diff: gm/colortype.cpp

Issue 14890016: start a wrapper for color fonts (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 7 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 | gyp/gmslides.gypi » ('j') | include/core/SkTypeface.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/colortype.cpp
diff --git a/gm/colortype.cpp b/gm/colortype.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..68576b853a28e0e37941cf5d353f23ddb2f50c1c
--- /dev/null
+++ b/gm/colortype.cpp
@@ -0,0 +1,68 @@
+/*
+ * 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 "SkGradientShader.h"
+#include "../src/fonts/SkGScalerContext.h"
+
+class ColorTypeGM : public skiagm::GM {
+public:
+ ColorTypeGM() {
+ const SkColor colors[] = {
+ SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE,
+ SK_ColorMAGENTA, SK_ColorCYAN, SK_ColorYELLOW
+ };
+ SkShader* s = SkGradientShader::CreateSweep(0,0, colors, NULL,
+ SK_ARRAY_COUNT(colors));
+ SkMatrix local;
+ local.setRotate(180);
+ s->setLocalMatrix(local);
+
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ paint.setShader(s)->unref();
+
+ SkAutoTUnref<SkTypeface> orig(SkTypeface::CreateFromName("Times",
+ SkTypeface::kBold));
+ fColorType = SkNEW_ARGS(SkGTypeface, (orig, paint));
+ }
+
+ virtual ~ColorTypeGM() {
+ fColorType->unref();
+ }
+
+protected:
+ virtual SkString onShortName() SK_OVERRIDE {
+ return SkString("colortype");
+ }
+
+ virtual SkISize onISize() SK_OVERRIDE {
+ return SkISize::Make(640, 480);
+ }
+
+ virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ paint.setTypeface(fColorType);
+
+ for (int size = 10; size <= 100; size += 10) {
+ paint.setTextSize(size);
+ canvas->translate(0, paint.getFontMetrics(NULL));
+ canvas->drawText("Hamburgefons", 12, 10, 10, paint);
+ }
+ }
+
+ virtual uint32_t onGetFlags() const { return kSkipPipe_Flag; }
+
+private:
+ SkTypeface* fColorType;
+
+ typedef skiagm::GM INHERITED;
+};
+
+DEF_GM( return SkNEW(ColorTypeGM); )
« no previous file with comments | « no previous file | gyp/gmslides.gypi » ('j') | include/core/SkTypeface.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698