OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 #include "GrTextureToYUVPlanes.h" | 8 #include "GrTextureToYUVPlanes.h" |
9 #include "effects/GrSimpleTextureEffect.h" | 9 #include "effects/GrSimpleTextureEffect.h" |
10 #include "effects/GrYUVEffect.h" | 10 #include "effects/GrYUVEffect.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
60 | 60 |
61 GrPixelConfig singleChannelPixelConfig; | 61 GrPixelConfig singleChannelPixelConfig; |
62 if (context->caps()->isConfigRenderable(kAlpha_8_GrPixelConfig, false)) { | 62 if (context->caps()->isConfigRenderable(kAlpha_8_GrPixelConfig, false)) { |
63 singleChannelPixelConfig = kAlpha_8_GrPixelConfig; | 63 singleChannelPixelConfig = kAlpha_8_GrPixelConfig; |
64 } else { | 64 } else { |
65 singleChannelPixelConfig = kRGBA_8888_GrPixelConfig; | 65 singleChannelPixelConfig = kRGBA_8888_GrPixelConfig; |
66 } | 66 } |
67 | 67 |
68 // We issue draw(s) to convert from RGBA to Y, U, and V. All three plane s may have different | 68 // We issue draw(s) to convert from RGBA to Y, U, and V. All three plane s may have different |
69 // sizes however we optimize for two other cases - all planes are the sa me (1 draw to YUV), | 69 // sizes however we optimize for two other cases - all planes are the sa me (1 draw to YUV), |
70 // and U and V are the same but Y differs (2 draws, one for Y, one for U V). | 70 // and U and V are the same but Y differs (2 draws, one for Y, one for U V). |
robertphillips
2016/07/21 19:22:41
What's up with the 'colorSpace' parameter ?
Brian Osman
2016/07/21 19:51:44
That defines the transform between RGB (in any col
| |
71 if (sizes[0] == sizes[1] && sizes[1] == sizes[2]) { | 71 if (sizes[0] == sizes[1] && sizes[1] == sizes[2]) { |
72 yuvDrawContext = context->newDrawContext(SkBackingFit::kApprox, | 72 yuvDrawContext = context->newDrawContext(SkBackingFit::kApprox, |
73 sizes[0].fWidth, sizes[0].f Height, | 73 sizes[0].fWidth, sizes[0].f Height, |
74 kRGBA_8888_GrPixelConfig); | 74 kRGBA_8888_GrPixelConfig, n ullptr); |
75 if (!yuvDrawContext) { | 75 if (!yuvDrawContext) { |
76 return false; | 76 return false; |
77 } | 77 } |
78 } else { | 78 } else { |
79 yDrawContext = context->newDrawContext(SkBackingFit::kApprox, | 79 yDrawContext = context->newDrawContext(SkBackingFit::kApprox, |
80 sizes[0].fWidth, sizes[0].fHe ight, | 80 sizes[0].fWidth, sizes[0].fHe ight, |
81 singleChannelPixelConfig); | 81 singleChannelPixelConfig, nul lptr); |
82 if (!yDrawContext) { | 82 if (!yDrawContext) { |
83 return false; | 83 return false; |
84 } | 84 } |
85 if (sizes[1] == sizes[2]) { | 85 if (sizes[1] == sizes[2]) { |
86 // TODO: Add support for GL_RG when available. | 86 // TODO: Add support for GL_RG when available. |
87 uvDrawContext = context->newDrawContext(SkBackingFit::kApprox, | 87 uvDrawContext = context->newDrawContext(SkBackingFit::kApprox, |
88 sizes[1].fWidth, sizes[1 ].fHeight, | 88 sizes[1].fWidth, sizes[1 ].fHeight, |
89 kRGBA_8888_GrPixelConfig ); | 89 kRGBA_8888_GrPixelConfig , nullptr); |
90 if (!uvDrawContext) { | 90 if (!uvDrawContext) { |
91 return false; | 91 return false; |
92 } | 92 } |
93 } else { | 93 } else { |
94 uDrawContext = context->newDrawContext(SkBackingFit::kApprox, | 94 uDrawContext = context->newDrawContext(SkBackingFit::kApprox, |
95 sizes[1].fWidth, sizes[1] .fHeight, | 95 sizes[1].fWidth, sizes[1] .fHeight, |
96 singleChannelPixelConfig) ; | 96 singleChannelPixelConfig, nullptr); |
97 vDrawContext = context->newDrawContext(SkBackingFit::kApprox, | 97 vDrawContext = context->newDrawContext(SkBackingFit::kApprox, |
98 sizes[2].fWidth, sizes[2] .fHeight, | 98 sizes[2].fWidth, sizes[2] .fHeight, |
99 singleChannelPixelConfig) ; | 99 singleChannelPixelConfig, nullptr); |
100 if (!uDrawContext || !vDrawContext) { | 100 if (!uDrawContext || !vDrawContext) { |
101 return false; | 101 return false; |
102 } | 102 } |
103 } | 103 } |
104 } | 104 } |
105 | 105 |
106 // Do all the draws before any readback. | 106 // Do all the draws before any readback. |
107 if (yuvDrawContext) { | 107 if (yuvDrawContext) { |
108 if (!convert_texture(texture, yuvDrawContext.get(), | 108 if (!convert_texture(texture, yuvDrawContext.get(), |
109 sizes[0].fWidth, sizes[0].fHeight, | 109 sizes[0].fWidth, sizes[0].fHeight, |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
221 if (!tex->readPixels(0, 0, sizes[2].fWidth, sizes[2].fHeight, | 221 if (!tex->readPixels(0, 0, sizes[2].fWidth, sizes[2].fHeight, |
222 kAlpha_8_GrPixelConfig, planes[2], rowBytes [2])) { | 222 kAlpha_8_GrPixelConfig, planes[2], rowBytes [2])) { |
223 return false; | 223 return false; |
224 } | 224 } |
225 return true; | 225 return true; |
226 } | 226 } |
227 } | 227 } |
228 } | 228 } |
229 return false; | 229 return false; |
230 } | 230 } |
OLD | NEW |