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 | 9 |
10 #include "GrDrawTargetCaps.h" | 10 #include "GrDrawTargetCaps.h" |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
233 SkYUVPlanesCache::Info yuvInfo; | 233 SkYUVPlanesCache::Info yuvInfo; |
234 SkAutoTUnref<SkCachedData> cachedData( | 234 SkAutoTUnref<SkCachedData> cachedData( |
235 SkYUVPlanesCache::FindAndRef(pixelRef->getGenerationID(), &yuvInfo)); | 235 SkYUVPlanesCache::FindAndRef(pixelRef->getGenerationID(), &yuvInfo)); |
236 | 236 |
237 void* planes[3]; | 237 void* planes[3]; |
238 if (cachedData && cachedData->data()) { | 238 if (cachedData && cachedData->data()) { |
239 planes[0] = (void*)cachedData->data(); | 239 planes[0] = (void*)cachedData->data(); |
240 planes[1] = (uint8_t*)planes[0] + yuvInfo.fSizeInMemory[0]; | 240 planes[1] = (uint8_t*)planes[0] + yuvInfo.fSizeInMemory[0]; |
241 planes[2] = (uint8_t*)planes[1] + yuvInfo.fSizeInMemory[1]; | 241 planes[2] = (uint8_t*)planes[1] + yuvInfo.fSizeInMemory[1]; |
242 } else { | 242 } else { |
243 SkISize optimalAllocationSizes[3]; | |
243 // Fetch yuv plane sizes for memory allocation. Here, width and height c an be | 244 // Fetch yuv plane sizes for memory allocation. Here, width and height c an be |
244 // rounded up to JPEG block size and be larger than the image's width an d height. | 245 // rounded up to JPEG block size and be larger than the image's width an d height. |
245 if (!pixelRef->getYUV8Planes(yuvInfo.fSize, NULL, NULL, NULL)) { | 246 if (!pixelRef->queryYUV8(yuvInfo.fSize, optimalAllocationSizes)) { |
246 return NULL; | 247 return NULL; |
247 } | 248 } |
248 | 249 |
249 // Allocate the memory for YUV | 250 // Allocate the memory for YUV |
250 size_t totalSize(0); | 251 size_t totalSize(0); |
251 for (int i = 0; i < 3; ++i) { | 252 for (int i = 0; i < 3; ++i) { |
252 yuvInfo.fRowBytes[i] = yuvInfo.fSize[i].fWidth; | 253 yuvInfo.fRowBytes[i] = optimalAllocationSizes[i].width(); |
253 yuvInfo.fSizeInMemory[i] = yuvInfo.fRowBytes[i] * yuvInfo.fSize[i].f Height; | 254 yuvInfo.fSizeInMemory[i] = yuvInfo.fRowBytes[i] * optimalAllocationS izes[i].height(); |
254 totalSize += yuvInfo.fSizeInMemory[i]; | 255 totalSize += yuvInfo.fSizeInMemory[i]; |
255 } | 256 } |
256 cachedData.reset(SkResourceCache::NewCachedData(totalSize)); | 257 cachedData.reset(SkResourceCache::NewCachedData(totalSize)); |
257 planes[0] = cachedData->writable_data(); | 258 planes[0] = cachedData->writable_data(); |
258 planes[1] = (uint8_t*)planes[0] + yuvInfo.fSizeInMemory[0]; | 259 planes[1] = (uint8_t*)planes[0] + yuvInfo.fSizeInMemory[0]; |
259 planes[2] = (uint8_t*)planes[1] + yuvInfo.fSizeInMemory[1]; | 260 planes[2] = (uint8_t*)planes[1] + yuvInfo.fSizeInMemory[1]; |
260 | 261 |
261 // Get the YUV planes and update plane sizes to actual image size | 262 // Get the YUV planes and update plane sizes to actual image size |
scroggo
2015/01/22 19:47:47
Does this comment still apply?
| |
262 if (!pixelRef->getYUV8Planes(yuvInfo.fSize, planes, yuvInfo.fRowBytes, | 263 if (!pixelRef->getYUV8(optimalAllocationSizes, planes, &yuvInfo.fColorSp ace)) { |
263 &yuvInfo.fColorSpace)) { | |
264 return NULL; | 264 return NULL; |
265 } | 265 } |
266 | 266 |
267 // Decoding is done, cache the resulting YUV planes | 267 // Decoding is done, cache the resulting YUV planes |
268 SkYUVPlanesCache::Add(pixelRef->getGenerationID(), cachedData, &yuvInfo) ; | 268 SkYUVPlanesCache::Add(pixelRef->getGenerationID(), cachedData, &yuvInfo) ; |
269 } | 269 } |
270 | 270 |
271 GrSurfaceDesc yuvDesc; | 271 GrSurfaceDesc yuvDesc; |
272 yuvDesc.fConfig = kAlpha_8_GrPixelConfig; | 272 yuvDesc.fConfig = kAlpha_8_GrPixelConfig; |
273 SkAutoTUnref<GrTexture> yuvTextures[3]; | 273 SkAutoTUnref<GrTexture> yuvTextures[3]; |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
590 if (shader->asFragmentProcessor(context, skPaint, viewM, NULL, &paintCol or, &fp) && fp) { | 590 if (shader->asFragmentProcessor(context, skPaint, viewM, NULL, &paintCol or, &fp) && fp) { |
591 grPaint->addColorProcessor(fp)->unref(); | 591 grPaint->addColorProcessor(fp)->unref(); |
592 constantColor = false; | 592 constantColor = false; |
593 } | 593 } |
594 } | 594 } |
595 | 595 |
596 // The grcolor is automatically set when calling asFragmentProcessor. | 596 // The grcolor is automatically set when calling asFragmentProcessor. |
597 // If the shader can be seen as an effect it returns true and adds its effec t to the grpaint. | 597 // If the shader can be seen as an effect it returns true and adds its effec t to the grpaint. |
598 SkPaint2GrPaintNoShader(context, skPaint, paintColor, constantColor, grPaint ); | 598 SkPaint2GrPaintNoShader(context, skPaint, paintColor, constantColor, grPaint ); |
599 } | 599 } |
OLD | NEW |