| 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 16 matching lines...) Expand all Loading... |
| 27 /** | 27 /** |
| 28 * This GM directly exercises GrYUVtoRGBEffect. | 28 * This GM directly exercises GrYUVtoRGBEffect. |
| 29 */ | 29 */ |
| 30 class YUVtoRGBEffect : public GM { | 30 class YUVtoRGBEffect : public GM { |
| 31 public: | 31 public: |
| 32 YUVtoRGBEffect() { | 32 YUVtoRGBEffect() { |
| 33 this->setBGColor(0xFFFFFFFF); | 33 this->setBGColor(0xFFFFFFFF); |
| 34 } | 34 } |
| 35 | 35 |
| 36 protected: | 36 protected: |
| 37 SkString onShortName() SK_OVERRIDE { | 37 SkString onShortName() override { |
| 38 return SkString("yuv_to_rgb_effect"); | 38 return SkString("yuv_to_rgb_effect"); |
| 39 } | 39 } |
| 40 | 40 |
| 41 SkISize onISize() SK_OVERRIDE { | 41 SkISize onISize() override { |
| 42 return SkISize::Make(238, 84); | 42 return SkISize::Make(238, 84); |
| 43 } | 43 } |
| 44 | 44 |
| 45 void onOnceBeforeDraw() SK_OVERRIDE { | 45 void onOnceBeforeDraw() override { |
| 46 SkImageInfo yinfo = SkImageInfo::MakeA8(YSIZE, YSIZE); | 46 SkImageInfo yinfo = SkImageInfo::MakeA8(YSIZE, YSIZE); |
| 47 fBmp[0].allocPixels(yinfo); | 47 fBmp[0].allocPixels(yinfo); |
| 48 SkImageInfo uinfo = SkImageInfo::MakeA8(USIZE, USIZE); | 48 SkImageInfo uinfo = SkImageInfo::MakeA8(USIZE, USIZE); |
| 49 fBmp[1].allocPixels(uinfo); | 49 fBmp[1].allocPixels(uinfo); |
| 50 SkImageInfo vinfo = SkImageInfo::MakeA8(VSIZE, VSIZE); | 50 SkImageInfo vinfo = SkImageInfo::MakeA8(VSIZE, VSIZE); |
| 51 fBmp[2].allocPixels(vinfo); | 51 fBmp[2].allocPixels(vinfo); |
| 52 unsigned char* pixels[3]; | 52 unsigned char* pixels[3]; |
| 53 for (int i = 0; i < 3; ++i) { | 53 for (int i = 0; i < 3; ++i) { |
| 54 pixels[i] = (unsigned char*)fBmp[i].getPixels(); | 54 pixels[i] = (unsigned char*)fBmp[i].getPixels(); |
| 55 } | 55 } |
| 56 int color[] = {0, 85, 170}; | 56 int color[] = {0, 85, 170}; |
| 57 const int limit[] = {255, 0, 255}; | 57 const int limit[] = {255, 0, 255}; |
| 58 const int invl[] = {0, 255, 0}; | 58 const int invl[] = {0, 255, 0}; |
| 59 const int inc[] = {1, -1, 1}; | 59 const int inc[] = {1, -1, 1}; |
| 60 for (int i = 0; i < 3; ++i) { | 60 for (int i = 0; i < 3; ++i) { |
| 61 const size_t nbBytes = fBmp[i].rowBytes() * fBmp[i].height(); | 61 const size_t nbBytes = fBmp[i].rowBytes() * fBmp[i].height(); |
| 62 for (size_t j = 0; j < nbBytes; ++j) { | 62 for (size_t j = 0; j < nbBytes; ++j) { |
| 63 pixels[i][j] = (unsigned char)color[i]; | 63 pixels[i][j] = (unsigned char)color[i]; |
| 64 color[i] = (color[i] == limit[i]) ? invl[i] : color[i] + inc[i]; | 64 color[i] = (color[i] == limit[i]) ? invl[i] : color[i] + inc[i]; |
| 65 } | 65 } |
| 66 } | 66 } |
| 67 } | 67 } |
| 68 | 68 |
| 69 void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 69 void onDraw(SkCanvas* canvas) override { |
| 70 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget
(); | 70 GrRenderTarget* rt = canvas->internal_private_accessTopLayerRenderTarget
(); |
| 71 if (NULL == rt) { | 71 if (NULL == rt) { |
| 72 return; | 72 return; |
| 73 } | 73 } |
| 74 GrContext* context = rt->getContext(); | 74 GrContext* context = rt->getContext(); |
| 75 if (NULL == context) { | 75 if (NULL == context) { |
| 76 this->drawGpuOnlyMessage(canvas); | 76 this->drawGpuOnlyMessage(canvas); |
| 77 return; | 77 return; |
| 78 } | 78 } |
| 79 | 79 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 private: | 136 private: |
| 137 SkBitmap fBmp[3]; | 137 SkBitmap fBmp[3]; |
| 138 | 138 |
| 139 typedef GM INHERITED; | 139 typedef GM INHERITED; |
| 140 }; | 140 }; |
| 141 | 141 |
| 142 DEF_GM( return SkNEW(YUVtoRGBEffect); ) | 142 DEF_GM( return SkNEW(YUVtoRGBEffect); ) |
| 143 } | 143 } |
| 144 | 144 |
| 145 #endif | 145 #endif |
| OLD | NEW |