| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 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 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 /** | 23 /** |
| 24 * This GM directly exercises GrYUVtoRGBEffect. | 24 * This GM directly exercises GrYUVtoRGBEffect. |
| 25 */ | 25 */ |
| 26 class YUVtoRGBEffect : public GM { | 26 class YUVtoRGBEffect : public GM { |
| 27 public: | 27 public: |
| 28 YUVtoRGBEffect() { | 28 YUVtoRGBEffect() { |
| 29 this->setBGColor(0xFFFFFFFF); | 29 this->setBGColor(0xFFFFFFFF); |
| 30 } | 30 } |
| 31 | 31 |
| 32 protected: | 32 protected: |
| 33 virtual SkString onShortName() SK_OVERRIDE { | 33 SkString onShortName() SK_OVERRIDE { |
| 34 return SkString("yuv_to_rgb_effect"); | 34 return SkString("yuv_to_rgb_effect"); |
| 35 } | 35 } |
| 36 | 36 |
| 37 virtual SkISize onISize() SK_OVERRIDE { | 37 SkISize onISize() SK_OVERRIDE { |
| 38 return SkISize::Make(334, 128); | 38 return SkISize::Make(334, 128); |
| 39 } | 39 } |
| 40 | 40 |
| 41 virtual uint32_t onGetFlags() const SK_OVERRIDE { | 41 uint32_t onGetFlags() const SK_OVERRIDE { |
| 42 // This is a GPU-specific GM. | 42 // This is a GPU-specific GM. |
| 43 return kGPUOnly_Flag; | 43 return kGPUOnly_Flag; |
| 44 } | 44 } |
| 45 | 45 |
| 46 virtual void onOnceBeforeDraw() SK_OVERRIDE { | 46 void onOnceBeforeDraw() SK_OVERRIDE { |
| 47 SkImageInfo info = SkImageInfo::MakeA8(24, 24); | 47 SkImageInfo info = SkImageInfo::MakeA8(24, 24); |
| 48 fBmp[0].allocPixels(info); | 48 fBmp[0].allocPixels(info); |
| 49 fBmp[1].allocPixels(info); | 49 fBmp[1].allocPixels(info); |
| 50 fBmp[2].allocPixels(info); | 50 fBmp[2].allocPixels(info); |
| 51 unsigned char* pixels[3]; | 51 unsigned char* pixels[3]; |
| 52 for (int i = 0; i < 3; ++i) { | 52 for (int i = 0; i < 3; ++i) { |
| 53 pixels[i] = (unsigned char*)fBmp[i].getPixels(); | 53 pixels[i] = (unsigned char*)fBmp[i].getPixels(); |
| 54 } | 54 } |
| 55 int color[] = {0, 85, 170}; | 55 int color[] = {0, 85, 170}; |
| 56 const int limit[] = {255, 0, 255}; | 56 const int limit[] = {255, 0, 255}; |
| 57 const int invl[] = {0, 255, 0}; | 57 const int invl[] = {0, 255, 0}; |
| 58 const int inc[] = {1, -1, 1}; | 58 const int inc[] = {1, -1, 1}; |
| 59 for (int j = 0; j < 576; ++j) { | 59 for (int j = 0; j < 576; ++j) { |
| 60 for (int i = 0; i < 3; ++i) { | 60 for (int i = 0; i < 3; ++i) { |
| 61 pixels[i][j] = (unsigned char)color[i]; | 61 pixels[i][j] = (unsigned char)color[i]; |
| 62 color[i] = (color[i] == limit[i]) ? invl[i] : color[i] + inc[i]; | 62 color[i] = (color[i] == limit[i]) ? invl[i] : color[i] + inc[i]; |
| 63 } | 63 } |
| 64 } | 64 } |
| 65 } | 65 } |
| 66 | 66 |
| 67 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 67 void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
| 68 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget
(); | 68 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget
(); |
| 69 if (NULL == rt) { | 69 if (NULL == rt) { |
| 70 return; | 70 return; |
| 71 } | 71 } |
| 72 GrContext* context = rt->getContext(); | 72 GrContext* context = rt->getContext(); |
| 73 if (NULL == context) { | 73 if (NULL == context) { |
| 74 return; | 74 return; |
| 75 } | 75 } |
| 76 | 76 |
| 77 GrTestTarget tt; | 77 GrTestTarget tt; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 private: | 128 private: |
| 129 SkBitmap fBmp[3]; | 129 SkBitmap fBmp[3]; |
| 130 | 130 |
| 131 typedef GM INHERITED; | 131 typedef GM INHERITED; |
| 132 }; | 132 }; |
| 133 | 133 |
| 134 DEF_GM( return SkNEW(YUVtoRGBEffect); ) | 134 DEF_GM( return SkNEW(YUVtoRGBEffect); ) |
| 135 } | 135 } |
| 136 | 136 |
| 137 #endif | 137 #endif |
| OLD | NEW |