OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
3 * | 3 * |
4 * 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 |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 // This test only works with the GPU backend. | 8 // This test only works with the GPU backend. |
9 | 9 |
10 #include "gm.h" | 10 #include "gm.h" |
11 | 11 |
12 #if SK_SUPPORT_GPU | 12 #if SK_SUPPORT_GPU |
13 | 13 |
14 #include "GrContext.h" | 14 #include "GrContext.h" |
15 #include "GrDrawContextPriv.h" | 15 #include "GrDrawContextPriv.h" |
16 #include "GrPipelineBuilder.h" | |
17 #include "SkBitmap.h" | 16 #include "SkBitmap.h" |
18 #include "SkGr.h" | 17 #include "SkGr.h" |
19 #include "SkGradientShader.h" | 18 #include "SkGradientShader.h" |
20 #include "batches/GrDrawBatch.h" | 19 #include "batches/GrDrawBatch.h" |
21 #include "batches/GrRectBatchFactory.h" | 20 #include "batches/GrRectBatchFactory.h" |
22 #include "effects/GrYUVEffect.h" | 21 #include "effects/GrYUVEffect.h" |
23 | 22 |
24 #define YSIZE 8 | 23 #define YSIZE 8 |
25 #define USIZE 4 | 24 #define USIZE 4 |
26 #define VSIZE 4 | 25 #define VSIZE 4 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 SkIntToScalar(fBmp[0].height())); | 105 SkIntToScalar(fBmp[0].height())); |
107 renderRect.outset(kDrawPad, kDrawPad); | 106 renderRect.outset(kDrawPad, kDrawPad); |
108 | 107 |
109 SkScalar y = kDrawPad + kTestPad + space * kColorSpaceOffset; | 108 SkScalar y = kDrawPad + kTestPad + space * kColorSpaceOffset; |
110 SkScalar x = kDrawPad + kTestPad; | 109 SkScalar x = kDrawPad + kTestPad; |
111 | 110 |
112 const int indices[6][3] = {{0, 1, 2}, {0, 2, 1}, {1, 0, 2}, | 111 const int indices[6][3] = {{0, 1, 2}, {0, 2, 1}, {1, 0, 2}, |
113 {1, 2, 0}, {2, 0, 1}, {2, 1, 0}}; | 112 {1, 2, 0}, {2, 0, 1}, {2, 1, 0}}; |
114 | 113 |
115 for (int i = 0; i < 6; ++i) { | 114 for (int i = 0; i < 6; ++i) { |
116 GrPipelineBuilder pipelineBuilder; | 115 GrPaint grPaint; |
117 pipelineBuilder.setXPFactory(GrPorterDuffXPFactory::Make(SkXferm
ode::kSrc_Mode)); | 116 grPaint.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSr
c_Mode)); |
118 sk_sp<GrFragmentProcessor> fp(GrYUVEffect::MakeYUVToRGB( | 117 sk_sp<GrFragmentProcessor> fp(GrYUVEffect::MakeYUVToRGB( |
119 texture[indices[i][0]], texture[indices[i][1]], texture[indi
ces[i][2]], sizes, | 118 texture[indices[i][0]], texture[indices[i][1]], texture[indi
ces[i][2]], sizes, |
120 static_cast<SkYUVColorSpace>(space), false)); | 119 static_cast<SkYUVColorSpace>(space), false)); |
121 if (fp) { | 120 if (fp) { |
122 SkMatrix viewMatrix; | 121 SkMatrix viewMatrix; |
123 viewMatrix.setTranslate(x, y); | 122 viewMatrix.setTranslate(x, y); |
124 pipelineBuilder.addColorFragmentProcessor(std::move(fp)); | 123 grPaint.addColorFragmentProcessor(std::move(fp)); |
125 SkAutoTUnref<GrDrawBatch> batch( | 124 SkAutoTUnref<GrDrawBatch> batch( |
126 GrRectBatchFactory::CreateNonAAFill(GrColor_WHITE, v
iewMatrix, | 125 GrRectBatchFactory::CreateNonAAFill(GrColor_WHITE, v
iewMatrix, |
127 renderRect, null
ptr, nullptr)); | 126 renderRect, null
ptr, nullptr)); |
128 drawContext->drawContextPriv().testingOnly_drawBatch(pipelin
eBuilder, batch); | 127 drawContext->drawContextPriv().testingOnly_drawBatch(grPaint
, batch); |
129 } | 128 } |
130 x += renderRect.width() + kTestPad; | 129 x += renderRect.width() + kTestPad; |
131 } | 130 } |
132 } | 131 } |
133 } | 132 } |
134 | 133 |
135 private: | 134 private: |
136 SkBitmap fBmp[3]; | 135 SkBitmap fBmp[3]; |
137 | 136 |
138 typedef GM INHERITED; | 137 typedef GM INHERITED; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 SkISize sizes[3] = {{YSIZE, YSIZE}, {USIZE, USIZE}, {VSIZE, VSIZE}}; | 217 SkISize sizes[3] = {{YSIZE, YSIZE}, {USIZE, USIZE}, {VSIZE, VSIZE}}; |
219 | 218 |
220 for (int space = kJPEG_SkYUVColorSpace; space <= kLastEnum_SkYUVColorSpa
ce; ++space) { | 219 for (int space = kJPEG_SkYUVColorSpace; space <= kLastEnum_SkYUVColorSpa
ce; ++space) { |
221 SkRect renderRect = | 220 SkRect renderRect = |
222 SkRect::MakeWH(SkIntToScalar(fBmp[0].width()), SkIntToScalar(fBm
p[0].height())); | 221 SkRect::MakeWH(SkIntToScalar(fBmp[0].width()), SkIntToScalar(fBm
p[0].height())); |
223 renderRect.outset(kDrawPad, kDrawPad); | 222 renderRect.outset(kDrawPad, kDrawPad); |
224 | 223 |
225 SkScalar y = kDrawPad + kTestPad + space * kColorSpaceOffset; | 224 SkScalar y = kDrawPad + kTestPad + space * kColorSpaceOffset; |
226 SkScalar x = kDrawPad + kTestPad; | 225 SkScalar x = kDrawPad + kTestPad; |
227 | 226 |
228 GrPipelineBuilder pipelineBuilder; | 227 GrPaint grPaint; |
229 pipelineBuilder.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode:
:kSrc_Mode)); | 228 grPaint.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mo
de)); |
230 sk_sp<GrFragmentProcessor> fp( | 229 sk_sp<GrFragmentProcessor> fp( |
231 GrYUVEffect::MakeYUVToRGB(texture[0], texture[1], texture[2], si
zes, | 230 GrYUVEffect::MakeYUVToRGB(texture[0], texture[1], texture[2], si
zes, |
232 static_cast<SkYUVColorSpace>(space), t
rue)); | 231 static_cast<SkYUVColorSpace>(space), t
rue)); |
233 if (fp) { | 232 if (fp) { |
234 SkMatrix viewMatrix; | 233 SkMatrix viewMatrix; |
235 viewMatrix.setTranslate(x, y); | 234 viewMatrix.setTranslate(x, y); |
236 pipelineBuilder.addColorFragmentProcessor(fp); | 235 grPaint.addColorFragmentProcessor(fp); |
237 SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAF
ill( | 236 SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAF
ill( |
238 GrColor_WHITE, viewMatrix, renderRect, nullptr, nullptr)); | 237 GrColor_WHITE, viewMatrix, renderRect, nullptr, nullptr)); |
239 drawContext->drawContextPriv().testingOnly_drawBatch(pipelineBui
lder, batch); | 238 drawContext->drawContextPriv().testingOnly_drawBatch(grPaint, ba
tch); |
240 } | 239 } |
241 } | 240 } |
242 } | 241 } |
243 | 242 |
244 private: | 243 private: |
245 SkBitmap fBmp[2]; | 244 SkBitmap fBmp[2]; |
246 | 245 |
247 typedef GM INHERITED; | 246 typedef GM INHERITED; |
248 }; | 247 }; |
249 | 248 |
250 DEF_GM(return new YUVNV12toRGBEffect;) | 249 DEF_GM(return new YUVNV12toRGBEffect;) |
251 } | 250 } |
252 | 251 |
253 #endif | 252 #endif |
OLD | NEW |