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 |
11 #include "gm.h" | 11 #include "gm.h" |
12 | 12 |
13 #if SK_SUPPORT_GPU | 13 #if SK_SUPPORT_GPU |
14 | 14 |
15 #include "GrContext.h" | 15 #include "GrContext.h" |
16 #include "GrDrawContext.h" | 16 #include "GrDrawContext.h" |
17 #include "GrPipelineBuilder.h" | 17 #include "GrPipelineBuilder.h" |
18 #include "SkBitmap.h" | 18 #include "SkBitmap.h" |
19 #include "SkGr.h" | 19 #include "SkGr.h" |
20 #include "SkGradientShader.h" | 20 #include "SkGradientShader.h" |
21 #include "batches/GrDrawBatch.h" | 21 #include "batches/GrDrawBatch.h" |
22 #include "batches/GrRectBatchFactory.h" | 22 #include "batches/GrRectBatchFactory.h" |
23 #include "effects/GrYUVtoRGBEffect.h" | 23 #include "effects/GrYUVEffect.h" |
24 | 24 |
25 #define YSIZE 8 | 25 #define YSIZE 8 |
26 #define USIZE 4 | 26 #define USIZE 4 |
27 #define VSIZE 4 | 27 #define VSIZE 4 |
28 | 28 |
29 namespace skiagm { | 29 namespace skiagm { |
30 /** | 30 /** |
31 * This GM directly exercises GrYUVtoRGBEffect. | 31 * This GM directly exercises GrYUVtoRGBEffect. |
32 */ | 32 */ |
33 class YUVtoRGBEffect : public GM { | 33 class YUVtoRGBEffect : public GM { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 SkScalar y = kDrawPad + kTestPad + space * kColorSpaceOffset; | 111 SkScalar y = kDrawPad + kTestPad + space * kColorSpaceOffset; |
112 SkScalar x = kDrawPad + kTestPad; | 112 SkScalar x = kDrawPad + kTestPad; |
113 | 113 |
114 const int indices[6][3] = {{0, 1, 2}, {0, 2, 1}, {1, 0, 2}, | 114 const int indices[6][3] = {{0, 1, 2}, {0, 2, 1}, {1, 0, 2}, |
115 {1, 2, 0}, {2, 0, 1}, {2, 1, 0}}; | 115 {1, 2, 0}, {2, 0, 1}, {2, 1, 0}}; |
116 | 116 |
117 for (int i = 0; i < 6; ++i) { | 117 for (int i = 0; i < 6; ++i) { |
118 GrPipelineBuilder pipelineBuilder; | 118 GrPipelineBuilder pipelineBuilder; |
119 pipelineBuilder.setXPFactory( | 119 pipelineBuilder.setXPFactory( |
120 GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref
(); | 120 GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref
(); |
121 SkAutoTUnref<GrFragmentProcessor> fp( | 121 SkAutoTUnref<const GrFragmentProcessor> fp( |
122 GrYUVtoRGBEffect::Create(texture[indices[i][0]], | 122 GrYUVEffect::CreateYUVToRGB(texture[indices[i][0]], |
123 texture[indices[i][1]], | 123 texture[indices[i][1]], |
124 texture[indices[i][2]], | 124 texture[indices[i][2]], |
125 sizes, | 125 sizes, |
126 static_cast<SkYUVColorSpace
>(space))); | 126 static_cast<SkYUVColorSp
ace>(space))); |
127 if (fp) { | 127 if (fp) { |
128 SkMatrix viewMatrix; | 128 SkMatrix viewMatrix; |
129 viewMatrix.setTranslate(x, y); | 129 viewMatrix.setTranslate(x, y); |
130 pipelineBuilder.setRenderTarget(rt); | 130 pipelineBuilder.setRenderTarget(rt); |
131 pipelineBuilder.addColorFragmentProcessor(fp); | 131 pipelineBuilder.addColorFragmentProcessor(fp); |
132 SkAutoTUnref<GrDrawBatch> batch( | 132 SkAutoTUnref<GrDrawBatch> batch( |
133 GrRectBatchFactory::CreateNonAAFill(GrColor_WHITE, v
iewMatrix, | 133 GrRectBatchFactory::CreateNonAAFill(GrColor_WHITE, v
iewMatrix, |
134 renderRect, null
ptr, nullptr)); | 134 renderRect, null
ptr, nullptr)); |
135 drawContext->internal_drawBatch(pipelineBuilder, batch); | 135 drawContext->internal_drawBatch(pipelineBuilder, batch); |
136 } | 136 } |
137 x += renderRect.width() + kTestPad; | 137 x += renderRect.width() + kTestPad; |
138 } | 138 } |
139 } | 139 } |
140 } | 140 } |
141 | 141 |
142 private: | 142 private: |
143 SkBitmap fBmp[3]; | 143 SkBitmap fBmp[3]; |
144 | 144 |
145 typedef GM INHERITED; | 145 typedef GM INHERITED; |
146 }; | 146 }; |
147 | 147 |
148 DEF_GM(return new YUVtoRGBEffect;) | 148 DEF_GM(return new YUVtoRGBEffect;) |
149 } | 149 } |
150 | 150 |
151 #endif | 151 #endif |
OLD | NEW |