2 * Copyright 2013 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
10 #include "SkGradientShader.h"
11 #include "../src/fonts/SkGScalerContext.h"
13 class ColorTypeGM : public skiagm::GM {
16 const SkColor colors[] = {
17 SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE,
18 SK_ColorMAGENTA, SK_ColorCYAN, SK_ColorYELLOW
22 SkShader* s = SkGradientShader::CreateSweep(0,0, colors, NULL,
23 SK_ARRAY_COUNT(colors), 0, &local);
26 paint.setAntiAlias(true);
27 paint.setShader(s)->unref();
29 SkTypeface* orig = sk_tool_utils::create_portable_typeface("Times",
32 orig = SkTypeface::RefDefault();
34 fColorType = SkNEW_ARGS(SkGTypeface, (orig, paint));
38 virtual ~ColorTypeGM() {
43 virtual SkString onShortName() SK_OVERRIDE {
44 return SkString("colortype");
47 virtual SkISize onISize() SK_OVERRIDE {
48 return SkISize::Make(640, 480);
51 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
53 paint.setAntiAlias(true);
54 paint.setTypeface(fColorType);
56 for (SkScalar size = 10; size <= 100; size += 10) {
57 paint.setTextSize(size);
58 canvas->translate(0, paint.getFontMetrics(NULL));
59 canvas->drawText("Hamburgefons", 12, 10, 10, paint);
63 virtual uint32_t onGetFlags() const {
64 return kSkipPipe_Flag | kSkipPicture_Flag;
68 SkTypeface* fColorType;
70 typedef skiagm::GM INHERITED;
73 DEF_GM( return SkNEW(ColorTypeGM); )