OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "gm.h" | 8 #include "gm.h" |
9 | 9 #include "SkShader.h" |
10 using namespace skiagm; | 10 using namespace skiagm; |
11 | 11 |
12 GM::GM() { | 12 GM::GM() { |
13 fMode = kGM_Mode; | 13 fMode = kGM_Mode; |
14 fBGColor = SK_ColorWHITE; | 14 fBGColor = SK_ColorWHITE; |
15 fCanvasIsDeferred = false; | 15 fCanvasIsDeferred = false; |
16 fHaveCalledOnceBeforeDraw = false; | 16 fHaveCalledOnceBeforeDraw = false; |
17 fStarterMatrix.reset(); | 17 fStarterMatrix.reset(); |
18 } | 18 } |
19 | 19 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 | 57 |
58 void GM::drawSizeBounds(SkCanvas* canvas, SkColor color) { | 58 void GM::drawSizeBounds(SkCanvas* canvas, SkColor color) { |
59 SkISize size = this->getISize(); | 59 SkISize size = this->getISize(); |
60 SkRect r = SkRect::MakeWH(SkIntToScalar(size.width()), | 60 SkRect r = SkRect::MakeWH(SkIntToScalar(size.width()), |
61 SkIntToScalar(size.height())); | 61 SkIntToScalar(size.height())); |
62 SkPaint paint; | 62 SkPaint paint; |
63 paint.setColor(color); | 63 paint.setColor(color); |
64 canvas->drawRect(r, paint); | 64 canvas->drawRect(r, paint); |
65 } | 65 } |
66 | 66 |
| 67 void GM::drawGpuOnlyMessage(SkCanvas* canvas) { |
| 68 SkBitmap bmp; |
| 69 bmp.allocN32Pixels(128, 64); |
| 70 SkCanvas bmpCanvas(bmp); |
| 71 bmpCanvas.drawColor(SK_ColorWHITE); |
| 72 SkPaint paint; |
| 73 paint.setAntiAlias(true); |
| 74 paint.setTextSize(20); |
| 75 paint.setColor(SK_ColorRED); |
| 76 static const char kTxt[] = "GPU Only"; |
| 77 bmpCanvas.drawText(kTxt, strlen(kTxt), 20, 40, paint); |
| 78 SkMatrix localM; |
| 79 localM.setRotate(35.f); |
| 80 localM.postTranslate(10.f, 0.f); |
| 81 SkAutoTUnref<SkShader> shader(SkShader::CreateBitmapShader(bmp, SkShader::kM
irror_TileMode, |
| 82 SkShader::kMirror
_TileMode, |
| 83 &localM)); |
| 84 paint.setShader(shader); |
| 85 paint.setFilterQuality(kMedium_SkFilterQuality); |
| 86 canvas->drawPaint(paint); |
| 87 return; |
| 88 } |
| 89 |
67 // need to explicitly declare this, or we get some weird infinite loop llist | 90 // need to explicitly declare this, or we get some weird infinite loop llist |
68 template GMRegistry* GMRegistry::gHead; | 91 template GMRegistry* GMRegistry::gHead; |
69 | 92 |
70 void skiagm::SimpleGM::onDraw(SkCanvas* canvas) { | 93 void skiagm::SimpleGM::onDraw(SkCanvas* canvas) { |
71 fDrawProc(canvas); | 94 fDrawProc(canvas); |
72 } | 95 } |
73 | 96 |
74 SkISize skiagm::SimpleGM::onISize() { | 97 SkISize skiagm::SimpleGM::onISize() { |
75 return fSize; | 98 return fSize; |
76 } | 99 } |
77 | 100 |
78 SkString skiagm::SimpleGM::onShortName() { | 101 SkString skiagm::SimpleGM::onShortName() { |
79 return fName; | 102 return fName; |
80 } | 103 } |
OLD | NEW |