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

Side by Side Diff: src/gpu/GrTextureToYUVPlanes.cpp

Issue 1663013004: Reduce stack usage for Google3. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 4 years, 10 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 | « no previous file | no next file » | 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 * 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
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
173 SkAutoSTMalloc<128 * 128, uint32_t> tempYUV(yuvSize.fWidth * yuvSize .fHeight); 177 SkAutoSTMalloc<128 * 128, uint32_t> tempYUV(yuvSize.fWidth * yuvSize .fHeight);
178 #endif
174 if (!yuvTex->readPixels(0, 0, yuvSize.fWidth, yuvSize.fHeight, 179 if (!yuvTex->readPixels(0, 0, yuvSize.fWidth, yuvSize.fHeight,
175 kRGBA_8888_GrPixelConfig, tempYUV.get(), 0)) { 180 kRGBA_8888_GrPixelConfig, tempYUV.get(), 0)) {
176 return false; 181 return false;
177 } 182 }
178 size_t yRowBytes = rowBytes[0] ? rowBytes[0] : yuvSize.fWidth; 183 size_t yRowBytes = rowBytes[0] ? rowBytes[0] : yuvSize.fWidth;
179 size_t uRowBytes = rowBytes[1] ? rowBytes[1] : yuvSize.fWidth; 184 size_t uRowBytes = rowBytes[1] ? rowBytes[1] : yuvSize.fWidth;
180 size_t vRowBytes = rowBytes[2] ? rowBytes[2] : yuvSize.fWidth; 185 size_t vRowBytes = rowBytes[2] ? rowBytes[2] : yuvSize.fWidth;
181 if (yRowBytes < (size_t)yuvSize.fWidth || uRowBytes < (size_t)yuvSiz e.fWidth || 186 if (yRowBytes < (size_t)yuvSize.fWidth || uRowBytes < (size_t)yuvSiz e.fWidth ||
182 vRowBytes < (size_t)yuvSize.fWidth) { 187 vRowBytes < (size_t)yuvSize.fWidth) {
183 return false; 188 return false;
(...skipping 16 matching lines...) Expand all
200 } else { 205 } else {
201 SkASSERT(yTex); 206 SkASSERT(yTex);
202 if (!yTex->readPixels(0, 0, sizes[0].fWidth, sizes[0].fHeight, 207 if (!yTex->readPixels(0, 0, sizes[0].fWidth, sizes[0].fHeight,
203 kAlpha_8_GrPixelConfig, planes[0], rowBytes[0] )) { 208 kAlpha_8_GrPixelConfig, planes[0], rowBytes[0] )) {
204 return false; 209 return false;
205 } 210 }
206 if (uvTex) { 211 if (uvTex) {
207 SkASSERT(sizes[1].fWidth == sizes[2].fWidth); 212 SkASSERT(sizes[1].fWidth == sizes[2].fWidth);
208 SkISize uvSize = sizes[1]; 213 SkISize uvSize = sizes[1];
209 // We have no kRG_88 pixel format, so readback rgba and then cop y two channels. 214 // 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
210 SkAutoSTMalloc<128 * 128, uint32_t> tempUV(uvSize.fWidth * uvSiz e.fHeight); 219 SkAutoSTMalloc<128 * 128, uint32_t> tempUV(uvSize.fWidth * uvSiz e.fHeight);
220 #endif
211 if (!uvTex->readPixels(0, 0, uvSize.fWidth, uvSize.fHeight, 221 if (!uvTex->readPixels(0, 0, uvSize.fWidth, uvSize.fHeight,
212 kRGBA_8888_GrPixelConfig, tempUV.get(), 0 )) { 222 kRGBA_8888_GrPixelConfig, tempUV.get(), 0 )) {
213 return false; 223 return false;
214 } 224 }
215 225
216 size_t uRowBytes = rowBytes[1] ? rowBytes[1] : uvSize.fWidth; 226 size_t uRowBytes = rowBytes[1] ? rowBytes[1] : uvSize.fWidth;
217 size_t vRowBytes = rowBytes[2] ? rowBytes[2] : uvSize.fWidth; 227 size_t vRowBytes = rowBytes[2] ? rowBytes[2] : uvSize.fWidth;
218 if (uRowBytes < (size_t)uvSize.fWidth || vRowBytes < (size_t)uvS ize.fWidth) { 228 if (uRowBytes < (size_t)uvSize.fWidth || vRowBytes < (size_t)uvS ize.fWidth) {
219 return false; 229 return false;
220 } 230 }
(...skipping 18 matching lines...) Expand all
239 if (!vTex->readPixels(0, 0, sizes[2].fWidth, sizes[2].fHeight, 249 if (!vTex->readPixels(0, 0, sizes[2].fWidth, sizes[2].fHeight,
240 kAlpha_8_GrPixelConfig, planes[2], rowByte s[2])) { 250 kAlpha_8_GrPixelConfig, planes[2], rowByte s[2])) {
241 return false; 251 return false;
242 } 252 }
243 return true; 253 return true;
244 } 254 }
245 } 255 }
246 } 256 }
247 return false; 257 return false;
248 } 258 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698