| OLD | NEW |
| 1 | |
| 2 /* | 1 /* |
| 3 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 4 * | 3 * |
| 5 * 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 |
| 6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 7 */ | 6 */ |
| 8 | 7 |
| 9 // This test only works with the GPU backend. | 8 // This test only works with the GPU backend. |
| 10 | 9 |
| 11 #include "gm.h" | 10 #include "gm.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 36 return SkString("const_color_processor"); | 35 return SkString("const_color_processor"); |
| 37 } | 36 } |
| 38 | 37 |
| 39 SkISize onISize() override { | 38 SkISize onISize() override { |
| 40 return SkISize::Make(kWidth, kHeight); | 39 return SkISize::Make(kWidth, kHeight); |
| 41 } | 40 } |
| 42 | 41 |
| 43 void onOnceBeforeDraw() override { | 42 void onOnceBeforeDraw() override { |
| 44 SkColor colors[] = { 0xFFFF0000, 0x2000FF00, 0xFF0000FF}; | 43 SkColor colors[] = { 0xFFFF0000, 0x2000FF00, 0xFF0000FF}; |
| 45 SkPoint pts[] = { SkPoint::Make(0, 0), SkPoint::Make(kRectSize, kRectSiz
e) }; | 44 SkPoint pts[] = { SkPoint::Make(0, 0), SkPoint::Make(kRectSize, kRectSiz
e) }; |
| 46 fShader.reset(SkGradientShader::CreateLinear(pts, colors, nullptr, SK_AR
RAY_COUNT(colors), | 45 fShader = SkGradientShader::MakeLinear(pts, colors, nullptr, SK_ARRAY_CO
UNT(colors), |
| 47 SkShader::kClamp_TileMode)); | 46 SkShader::kClamp_TileMode); |
| 48 } | 47 } |
| 49 | 48 |
| 50 void onDraw(SkCanvas* canvas) override { | 49 void onDraw(SkCanvas* canvas) override { |
| 51 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget
(); | 50 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget
(); |
| 52 if (nullptr == rt) { | 51 if (nullptr == rt) { |
| 53 return; | 52 return; |
| 54 } | 53 } |
| 55 GrContext* context = rt->getContext(); | 54 GrContext* context = rt->getContext(); |
| 56 if (nullptr == context) { | 55 if (nullptr == context) { |
| 57 skiagm::GM::DrawGpuOnlyMessage(canvas); | 56 skiagm::GM::DrawGpuOnlyMessage(canvas); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 x += maxW + kPad; | 171 x += maxW + kPad; |
| 173 maxW = 0; | 172 maxW = 0; |
| 174 } | 173 } |
| 175 } | 174 } |
| 176 } | 175 } |
| 177 } | 176 } |
| 178 } | 177 } |
| 179 | 178 |
| 180 private: | 179 private: |
| 181 // Use this as a way of generating and input FP | 180 // Use this as a way of generating and input FP |
| 182 SkAutoTUnref<SkShader> fShader; | 181 sk_sp<SkShader> fShader; |
| 183 | 182 |
| 184 static const SkScalar kPad; | 183 static const SkScalar kPad; |
| 185 static const SkScalar kRectSize; | 184 static const SkScalar kRectSize; |
| 186 static const int kWidth = 820; | 185 static const int kWidth = 820; |
| 187 static const int kHeight = 500; | 186 static const int kHeight = 500; |
| 188 | 187 |
| 189 typedef GM INHERITED; | 188 typedef GM INHERITED; |
| 190 }; | 189 }; |
| 191 | 190 |
| 192 const SkScalar ConstColorProcessor::kPad = 10.f; | 191 const SkScalar ConstColorProcessor::kPad = 10.f; |
| 193 const SkScalar ConstColorProcessor::kRectSize = 20.f; | 192 const SkScalar ConstColorProcessor::kRectSize = 20.f; |
| 194 | 193 |
| 195 DEF_GM(return new ConstColorProcessor;) | 194 DEF_GM(return new ConstColorProcessor;) |
| 196 } | 195 } |
| 197 | 196 |
| 198 #endif | 197 #endif |
| OLD | NEW |