| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 // This test only works with the GPU backend. | 9 // This test only works with the GPU backend. |
| 10 | 10 |
| 11 #include "gm.h" | 11 #include "gm.h" |
| 12 | 12 |
| 13 #if SK_SUPPORT_GPU | 13 #if SK_SUPPORT_GPU |
| 14 #include "GrContext.h" | 14 #include "GrContext.h" |
| 15 #include "effects/GrSimpleTextureEffect.h" | 15 #include "effects/GrSimpleTextureEffect.h" |
| 16 #include "SkColorPriv.h" | 16 #include "SkColorPriv.h" |
| 17 #include "SkDevice.h" | |
| 18 | 17 |
| 19 namespace skiagm { | 18 namespace skiagm { |
| 20 | 19 |
| 21 static const int S = 200; | 20 static const int S = 200; |
| 22 | 21 |
| 23 class TexDataGM : public GM { | 22 class TexDataGM : public GM { |
| 24 public: | 23 public: |
| 25 TexDataGM() { | 24 TexDataGM() { |
| 26 this->setBGColor(0xff000000); | 25 this->setBGColor(0xff000000); |
| 27 } | 26 } |
| 28 | 27 |
| 29 protected: | 28 protected: |
| 30 virtual SkString onShortName() { | 29 virtual SkString onShortName() { |
| 31 return SkString("texdata"); | 30 return SkString("texdata"); |
| 32 } | 31 } |
| 33 | 32 |
| 34 virtual SkISize onISize() { | 33 virtual SkISize onISize() { |
| 35 return make_isize(2*S, 2*S); | 34 return make_isize(2*S, 2*S); |
| 36 } | 35 } |
| 37 | 36 |
| 38 virtual uint32_t onGetFlags() const SK_OVERRIDE { return kGPUOnly_Flag; } | 37 virtual uint32_t onGetFlags() const SK_OVERRIDE { return kGPUOnly_Flag; } |
| 39 | 38 |
| 40 virtual void onDraw(SkCanvas* canvas) { | 39 virtual void onDraw(SkCanvas* canvas) { |
| 41 SkBaseDevice* device = canvas->getTopDevice(); | 40 GrRenderTarget* target = canvas->internal_private_accessTopLayerRenderTa
rget(); |
| 42 GrRenderTarget* target = device->accessRenderTarget(); | |
| 43 GrContext* ctx = canvas->getGrContext(); | 41 GrContext* ctx = canvas->getGrContext(); |
| 44 if (ctx && target) { | 42 if (ctx && target) { |
| 45 SkAutoTArray<SkPMColor> gTextureData((2 * S) * (2 * S)); | 43 SkAutoTArray<SkPMColor> gTextureData((2 * S) * (2 * S)); |
| 46 static const int stride = 2 * S; | 44 static const int stride = 2 * S; |
| 47 static const SkPMColor gray = SkPackARGB32(0x40, 0x40, 0x40, 0x40); | 45 static const SkPMColor gray = SkPackARGB32(0x40, 0x40, 0x40, 0x40); |
| 48 static const SkPMColor white = SkPackARGB32(0xff, 0xff, 0xff, 0xff); | 46 static const SkPMColor white = SkPackARGB32(0xff, 0xff, 0xff, 0xff); |
| 49 static const SkPMColor red = SkPackARGB32(0x80, 0x80, 0x00, 0x00); | 47 static const SkPMColor red = SkPackARGB32(0x80, 0x80, 0x00, 0x00); |
| 50 static const SkPMColor blue = SkPackARGB32(0x80, 0x00, 0x00, 0x80); | 48 static const SkPMColor blue = SkPackARGB32(0x80, 0x00, 0x00, 0x80); |
| 51 static const SkPMColor green = SkPackARGB32(0x80, 0x00, 0x80, 0x00); | 49 static const SkPMColor green = SkPackARGB32(0x80, 0x00, 0x80, 0x00); |
| 52 static const SkPMColor black = SkPackARGB32(0x00, 0x00, 0x00, 0x00); | 50 static const SkPMColor black = SkPackARGB32(0x00, 0x00, 0x00, 0x00); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 }; | 137 }; |
| 140 | 138 |
| 141 ////////////////////////////////////////////////////////////////////////////// | 139 ////////////////////////////////////////////////////////////////////////////// |
| 142 | 140 |
| 143 static GM* MyFactory(void*) { return new TexDataGM; } | 141 static GM* MyFactory(void*) { return new TexDataGM; } |
| 144 static GMRegistry reg(MyFactory); | 142 static GMRegistry reg(MyFactory); |
| 145 | 143 |
| 146 } | 144 } |
| 147 | 145 |
| 148 #endif | 146 #endif |
| OLD | NEW |