OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 #if SK_SUPPORT_GPU | 9 #if SK_SUPPORT_GPU |
10 #include "GrContext.h" | 10 #include "GrContext.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 return name; | 60 return name; |
61 } | 61 } |
62 | 62 |
63 SkISize onISize() override { return SkISize::Make(kImageWidth, kImageHeight)
; } | 63 SkISize onISize() override { return SkISize::Make(kImageWidth, kImageHeight)
; } |
64 | 64 |
65 void onDraw(SkCanvas* canvas) override { | 65 void onDraw(SkCanvas* canvas) override { |
66 GrContext* context = nullptr; | 66 GrContext* context = nullptr; |
67 #if SK_SUPPORT_GPU | 67 #if SK_SUPPORT_GPU |
68 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget
(); | 68 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget
(); |
69 context = rt ? rt->getContext() : nullptr; | 69 context = rt ? rt->getContext() : nullptr; |
70 SkAutoTUnref<GrDrawContext> drawContext(context->drawContext(rt)); | 70 SkAutoTUnref<GrDrawContext> drawContext; |
71 if (!drawContext) { | 71 if (kEffect_Type == fType) { |
72 return; | 72 if (!context) { |
| 73 skiagm::GM::DrawGpuOnlyMessage(canvas); |
| 74 return; |
| 75 } |
| 76 |
| 77 drawContext.reset(context->drawContext(rt)); |
| 78 if (!drawContext) { |
| 79 return; |
| 80 } |
73 } | 81 } |
74 #endif | 82 #endif |
75 if (kEffect_Type == fType && nullptr == context) { | 83 if (kEffect_Type == fType && nullptr == context) { |
76 skiagm::GM::DrawGpuOnlyMessage(canvas); | 84 skiagm::GM::DrawGpuOnlyMessage(canvas); |
77 return; | 85 return; |
78 } | 86 } |
79 | 87 |
80 SkPaint paint; | 88 SkPaint paint; |
81 if (kAA_Draw_Type == fType) { | 89 if (kAA_Draw_Type == fType) { |
82 paint.setAntiAlias(true); | 90 paint.setAntiAlias(true); |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 | 271 |
264 DEF_GM( return new RRectGM(RRectGM::kAA_Draw_Type); ) | 272 DEF_GM( return new RRectGM(RRectGM::kAA_Draw_Type); ) |
265 DEF_GM( return new RRectGM(RRectGM::kBW_Draw_Type); ) | 273 DEF_GM( return new RRectGM(RRectGM::kBW_Draw_Type); ) |
266 DEF_GM( return new RRectGM(RRectGM::kAA_Clip_Type); ) | 274 DEF_GM( return new RRectGM(RRectGM::kAA_Clip_Type); ) |
267 DEF_GM( return new RRectGM(RRectGM::kBW_Clip_Type); ) | 275 DEF_GM( return new RRectGM(RRectGM::kBW_Clip_Type); ) |
268 #if SK_SUPPORT_GPU | 276 #if SK_SUPPORT_GPU |
269 DEF_GM( return new RRectGM(RRectGM::kEffect_Type); ) | 277 DEF_GM( return new RRectGM(RRectGM::kEffect_Type); ) |
270 #endif | 278 #endif |
271 | 279 |
272 } | 280 } |
OLD | NEW |