OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 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 "SkGr.h" | 8 #include "SkGr.h" |
9 #include "SkColorFilter.h" | 9 #include "SkColorFilter.h" |
10 #include "SkConfig8888.h" | 10 #include "SkConfig8888.h" |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
213 } else { | 213 } else { |
214 return NULL; | 214 return NULL; |
215 } | 215 } |
216 | 216 |
217 return sk_gr_allocate_texture(ctx, cache, params, bm, desc, bytes, 0); | 217 return sk_gr_allocate_texture(ctx, cache, params, bm, desc, bytes, 0); |
218 } | 218 } |
219 #endif // SK_IGNORE_ETC1_SUPPORT | 219 #endif // SK_IGNORE_ETC1_SUPPORT |
220 | 220 |
221 static GrTexture *load_yuv_texture(GrContext* ctx, bool cache, const GrTexturePa rams* params, | 221 static GrTexture *load_yuv_texture(GrContext* ctx, bool cache, const GrTexturePa rams* params, |
222 const SkBitmap& bm, const GrTextureDesc& desc ) { | 222 const SkBitmap& bm, const GrTextureDesc& desc ) { |
223 SkPixelRef* pixelRef = bm.pixelRef(); | 223 // Subsets are not supported, the whole pixelRef is loaded when using YUV de coding |
224 SkISize yuvSizes[3]; | 224 if ((bm.pixelRef()->info().width() != bm.info().width()) || |
225 if ((NULL == pixelRef) || !pixelRef->getYUV8Planes(yuvSizes, NULL, NULL, NUL L)) { | 225 (bm.pixelRef()->info().height() != bm.info().height())) { |
226 return NULL; | 226 return NULL; |
227 } | 227 } |
228 | 228 |
229 SkPixelRef* pixelRef = bm.pixelRef(); | |
230 SkISize yuvSizes[3]; | |
231 const int maxTextureSize = ctx->getMaxTextureSize(); | |
232 if ((NULL == pixelRef) || !pixelRef->getYUV8Planes(yuvSizes, NULL, NULL, NUL L) || | |
bsalomon
2014/10/15 15:34:42
Should the failure happen in getYUV8Planes rather
sugoi1
2014/10/15 18:13:28
getYUV8Planes() doesn't know anything about the bi
bsalomon
2014/10/15 18:31:54
Acknowledged.
| |
233 (yuvSizes[0].fWidth > maxTextureSize) || (yuvSizes[0].fHeight > maxTextu reSize) || | |
234 (yuvSizes[1].fWidth > maxTextureSize) || (yuvSizes[1].fHeight > maxTextu reSize) || | |
bsalomon
2014/10/15 15:34:42
Are these checks needed?
sugoi1
2014/10/15 18:13:28
Well, it's not impossible that these would be requ
bsalomon
2014/10/15 18:31:54
In any case, wouldn't we just fail down below in r
sugoi1
2014/10/15 19:08:56
Ah, well, if that's the case I'll just remove thes
| |
235 (yuvSizes[2].fWidth > maxTextureSize) || (yuvSizes[2].fHeight > maxTextu reSize)) { | |
236 return NULL; | |
237 } | |
238 | |
229 // Allocate the memory for YUV | 239 // Allocate the memory for YUV |
230 size_t totalSize(0); | 240 size_t totalSize(0); |
231 size_t sizes[3], rowBytes[3]; | 241 size_t sizes[3], rowBytes[3]; |
232 for (int i = 0; i < 3; ++i) { | 242 for (int i = 0; i < 3; ++i) { |
233 rowBytes[i] = yuvSizes[i].fWidth; | 243 rowBytes[i] = yuvSizes[i].fWidth; |
234 totalSize += sizes[i] = rowBytes[i] * yuvSizes[i].fHeight; | 244 totalSize += sizes[i] = rowBytes[i] * yuvSizes[i].fHeight; |
235 } | 245 } |
236 SkAutoMalloc storage(totalSize); | 246 SkAutoMalloc storage(totalSize); |
237 void* planes[3]; | 247 void* planes[3]; |
238 planes[0] = storage.get(); | 248 planes[0] = storage.get(); |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
569 if (shader->asFragmentProcessor(context, skPaint, NULL, &paintColor, &fp ) && fp) { | 579 if (shader->asFragmentProcessor(context, skPaint, NULL, &paintColor, &fp ) && fp) { |
570 grPaint->addColorProcessor(fp)->unref(); | 580 grPaint->addColorProcessor(fp)->unref(); |
571 constantColor = false; | 581 constantColor = false; |
572 } | 582 } |
573 } | 583 } |
574 | 584 |
575 // The grcolor is automatically set when calling asFragmentProcessor. | 585 // The grcolor is automatically set when calling asFragmentProcessor. |
576 // If the shader can be seen as an effect it returns true and adds its effec t to the grpaint. | 586 // If the shader can be seen as an effect it returns true and adds its effec t to the grpaint. |
577 SkPaint2GrPaintNoShader(context, skPaint, paintColor, constantColor, grPaint ); | 587 SkPaint2GrPaintNoShader(context, skPaint, paintColor, constantColor, grPaint ); |
578 } | 588 } |
OLD | NEW |