Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(304)

Side by Side Diff: gm/yuvtorgbeffect.cpp

Issue 516463005: Add support for the Rec601 YUV color space to GrYUVtoRGBEffect. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: use float literals to make VS happy Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « expectations/gm/ignored-tests.txt ('k') | include/core/SkImageGenerator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 17 matching lines...) Expand all
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 virtual 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 virtual SkISize onISize() SK_OVERRIDE {
38 return SkISize::Make(334, 64); 38 return SkISize::Make(334, 128);
39 } 39 }
40 40
41 virtual uint32_t onGetFlags() const SK_OVERRIDE { 41 virtual 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 virtual 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);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 GrTexture* texture[3]; 86 GrTexture* texture[3];
87 texture[0] = GrLockAndRefCachedBitmapTexture(context, fBmp[0], NULL); 87 texture[0] = GrLockAndRefCachedBitmapTexture(context, fBmp[0], NULL);
88 texture[1] = GrLockAndRefCachedBitmapTexture(context, fBmp[1], NULL); 88 texture[1] = GrLockAndRefCachedBitmapTexture(context, fBmp[1], NULL);
89 texture[2] = GrLockAndRefCachedBitmapTexture(context, fBmp[2], NULL); 89 texture[2] = GrLockAndRefCachedBitmapTexture(context, fBmp[2], NULL);
90 if ((NULL == texture[0]) || (NULL == texture[1]) || (NULL == texture[2]) ) { 90 if ((NULL == texture[0]) || (NULL == texture[1]) || (NULL == texture[2]) ) {
91 return; 91 return;
92 } 92 }
93 93
94 static const SkScalar kDrawPad = 10.f; 94 static const SkScalar kDrawPad = 10.f;
95 static const SkScalar kTestPad = 10.f; 95 static const SkScalar kTestPad = 10.f;
96 static const SkScalar kColorSpaceOffset = 64.f;
96 97
97 SkRect renderRect = SkRect::MakeWH(SkIntToScalar(fBmp[0].width()), 98 for (int space = kJPEG_SkYUVColorSpace; space <= kLastEnum_SkYUVColorSpa ce;
98 SkIntToScalar(fBmp[0].height())); 99 ++space) {
99 renderRect.outset(kDrawPad, kDrawPad); 100 SkRect renderRect = SkRect::MakeWH(SkIntToScalar(fBmp[0].width()),
101 SkIntToScalar(fBmp[0].height()));
102 renderRect.outset(kDrawPad, kDrawPad);
100 103
101 SkScalar y = kDrawPad + kTestPad; 104 SkScalar y = kDrawPad + kTestPad + space * kColorSpaceOffset;
102 SkScalar x = kDrawPad + kTestPad; 105 SkScalar x = kDrawPad + kTestPad;
103 106
104 const int indices[6][3] = {{0, 1, 2}, {0, 2, 1}, {1, 0, 2}, {1, 2, 0}, { 2, 0, 1}, {2, 1, 0}}; 107 const int indices[6][3] = {{0, 1, 2}, {0, 2, 1}, {1, 0, 2}, {1, 2, 0}, {2, 0, 1}, {2, 1, 0}};
105 108
106 for (int i = 0; i < 6; ++i) { 109 for (int i = 0; i < 6; ++i) {
107 SkAutoTUnref<GrEffect> effect( 110 SkAutoTUnref<GrEffect> effect(
108 GrYUVtoRGBEffect::Create(texture[indices[i][0]], 111 GrYUVtoRGBEffect::Create(texture[indices[i][0]],
109 texture[indices[i][1]], 112 texture[indices[i][1]],
110 texture[indices[i][2]])); 113 texture[indices[i][2]],
111 if (effect) { 114 static_cast<SkYUVColorSpace>( space)));
112 SkMatrix viewMatrix; 115 if (effect) {
113 viewMatrix.setTranslate(x, y); 116 SkMatrix viewMatrix;
114 drawState->reset(viewMatrix); 117 viewMatrix.setTranslate(x, y);
115 drawState->setRenderTarget(rt); 118 drawState->reset(viewMatrix);
116 drawState->setColor(0xffffffff); 119 drawState->setRenderTarget(rt);
117 drawState->addColorEffect(effect, 1); 120 drawState->setColor(0xffffffff);
118 tt.target()->drawSimpleRect(renderRect); 121 drawState->addColorEffect(effect, 1);
119 } 122 tt.target()->drawSimpleRect(renderRect);
120 x += renderRect.width() + kTestPad; 123 }
124 x += renderRect.width() + kTestPad;
125 }
121 } 126 }
122 127
123 GrUnlockAndUnrefCachedBitmapTexture(texture[0]); 128 GrUnlockAndUnrefCachedBitmapTexture(texture[0]);
124 GrUnlockAndUnrefCachedBitmapTexture(texture[1]); 129 GrUnlockAndUnrefCachedBitmapTexture(texture[1]);
125 GrUnlockAndUnrefCachedBitmapTexture(texture[2]); 130 GrUnlockAndUnrefCachedBitmapTexture(texture[2]);
126 } 131 }
127 132
128 private: 133 private:
129 SkBitmap fBmp[3]; 134 SkBitmap fBmp[3];
130 135
131 typedef GM INHERITED; 136 typedef GM INHERITED;
132 }; 137 };
133 138
134 DEF_GM( return SkNEW(YUVtoRGBEffect); ) 139 DEF_GM( return SkNEW(YUVtoRGBEffect); )
135 } 140 }
136 141
137 #endif 142 #endif
OLDNEW
« no previous file with comments | « expectations/gm/ignored-tests.txt ('k') | include/core/SkImageGenerator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698