| 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 colorSpace, GrYUVEffect::CreateRGBToV)) { | 163 colorSpace, GrYUVEffect::CreateRGBToV)) { |
| 164 return false; | 164 return false; |
| 165 } | 165 } |
| 166 } | 166 } |
| 167 } | 167 } |
| 168 | 168 |
| 169 if (yuvTex) { | 169 if (yuvTex) { |
| 170 SkASSERT(sizes[0] == sizes[1] && sizes[1] == sizes[2]); | 170 SkASSERT(sizes[0] == sizes[1] && sizes[1] == sizes[2]); |
| 171 SkISize yuvSize = sizes[0]; | 171 SkISize yuvSize = sizes[0]; |
| 172 // We have no kRGB_888 pixel format, so readback rgba and then copy
three channels. | 172 // We have no kRGB_888 pixel format, so readback rgba and then copy
three channels. |
| 173 #if defined(GOOGLE3) | |
| 174 // Stack frame size is limited in GOOGLE3. | |
| 175 SkAutoSTMalloc<48 * 48, uint32_t> tempYUV(yuvSize.fWidth * yuvSize.f
Height); | |
| 176 #else | |
| 177 SkAutoSTMalloc<128 * 128, uint32_t> tempYUV(yuvSize.fWidth * yuvSize
.fHeight); | 173 SkAutoSTMalloc<128 * 128, uint32_t> tempYUV(yuvSize.fWidth * yuvSize
.fHeight); |
| 178 #endif | |
| 179 if (!yuvTex->readPixels(0, 0, yuvSize.fWidth, yuvSize.fHeight, | 174 if (!yuvTex->readPixels(0, 0, yuvSize.fWidth, yuvSize.fHeight, |
| 180 kRGBA_8888_GrPixelConfig, tempYUV.get(), 0))
{ | 175 kRGBA_8888_GrPixelConfig, tempYUV.get(), 0))
{ |
| 181 return false; | 176 return false; |
| 182 } | 177 } |
| 183 size_t yRowBytes = rowBytes[0] ? rowBytes[0] : yuvSize.fWidth; | 178 size_t yRowBytes = rowBytes[0] ? rowBytes[0] : yuvSize.fWidth; |
| 184 size_t uRowBytes = rowBytes[1] ? rowBytes[1] : yuvSize.fWidth; | 179 size_t uRowBytes = rowBytes[1] ? rowBytes[1] : yuvSize.fWidth; |
| 185 size_t vRowBytes = rowBytes[2] ? rowBytes[2] : yuvSize.fWidth; | 180 size_t vRowBytes = rowBytes[2] ? rowBytes[2] : yuvSize.fWidth; |
| 186 if (yRowBytes < (size_t)yuvSize.fWidth || uRowBytes < (size_t)yuvSiz
e.fWidth || | 181 if (yRowBytes < (size_t)yuvSize.fWidth || uRowBytes < (size_t)yuvSiz
e.fWidth || |
| 187 vRowBytes < (size_t)yuvSize.fWidth) { | 182 vRowBytes < (size_t)yuvSize.fWidth) { |
| 188 return false; | 183 return false; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 205 } else { | 200 } else { |
| 206 SkASSERT(yTex); | 201 SkASSERT(yTex); |
| 207 if (!yTex->readPixels(0, 0, sizes[0].fWidth, sizes[0].fHeight, | 202 if (!yTex->readPixels(0, 0, sizes[0].fWidth, sizes[0].fHeight, |
| 208 kAlpha_8_GrPixelConfig, planes[0], rowBytes[0]
)) { | 203 kAlpha_8_GrPixelConfig, planes[0], rowBytes[0]
)) { |
| 209 return false; | 204 return false; |
| 210 } | 205 } |
| 211 if (uvTex) { | 206 if (uvTex) { |
| 212 SkASSERT(sizes[1].fWidth == sizes[2].fWidth); | 207 SkASSERT(sizes[1].fWidth == sizes[2].fWidth); |
| 213 SkISize uvSize = sizes[1]; | 208 SkISize uvSize = sizes[1]; |
| 214 // We have no kRG_88 pixel format, so readback rgba and then cop
y two channels. | 209 // We have no kRG_88 pixel format, so readback rgba and then cop
y two channels. |
| 215 #if defined(GOOGLE3) | |
| 216 // Stack frame size is limited in GOOGLE3. | |
| 217 SkAutoSTMalloc<48 * 48, uint32_t> tempUV(uvSize.fWidth * uvSize.
fHeight); | |
| 218 #else | |
| 219 SkAutoSTMalloc<128 * 128, uint32_t> tempUV(uvSize.fWidth * uvSiz
e.fHeight); | 210 SkAutoSTMalloc<128 * 128, uint32_t> tempUV(uvSize.fWidth * uvSiz
e.fHeight); |
| 220 #endif | |
| 221 if (!uvTex->readPixels(0, 0, uvSize.fWidth, uvSize.fHeight, | 211 if (!uvTex->readPixels(0, 0, uvSize.fWidth, uvSize.fHeight, |
| 222 kRGBA_8888_GrPixelConfig, tempUV.get(), 0
)) { | 212 kRGBA_8888_GrPixelConfig, tempUV.get(), 0
)) { |
| 223 return false; | 213 return false; |
| 224 } | 214 } |
| 225 | 215 |
| 226 size_t uRowBytes = rowBytes[1] ? rowBytes[1] : uvSize.fWidth; | 216 size_t uRowBytes = rowBytes[1] ? rowBytes[1] : uvSize.fWidth; |
| 227 size_t vRowBytes = rowBytes[2] ? rowBytes[2] : uvSize.fWidth; | 217 size_t vRowBytes = rowBytes[2] ? rowBytes[2] : uvSize.fWidth; |
| 228 if (uRowBytes < (size_t)uvSize.fWidth || vRowBytes < (size_t)uvS
ize.fWidth) { | 218 if (uRowBytes < (size_t)uvSize.fWidth || vRowBytes < (size_t)uvS
ize.fWidth) { |
| 229 return false; | 219 return false; |
| 230 } | 220 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 249 if (!vTex->readPixels(0, 0, sizes[2].fWidth, sizes[2].fHeight, | 239 if (!vTex->readPixels(0, 0, sizes[2].fWidth, sizes[2].fHeight, |
| 250 kAlpha_8_GrPixelConfig, planes[2], rowByte
s[2])) { | 240 kAlpha_8_GrPixelConfig, planes[2], rowByte
s[2])) { |
| 251 return false; | 241 return false; |
| 252 } | 242 } |
| 253 return true; | 243 return true; |
| 254 } | 244 } |
| 255 } | 245 } |
| 256 } | 246 } |
| 257 return false; | 247 return false; |
| 258 } | 248 } |
| OLD | NEW |