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

Unified Diff: src/gpu/GrYUVProvider.cpp

Issue 1775493002: Revert of Update Skia's YUV API (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrYUVProvider.h ('k') | src/gpu/SkGr.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrYUVProvider.cpp
diff --git a/src/gpu/GrYUVProvider.cpp b/src/gpu/GrYUVProvider.cpp
index 708cbecb11ff9100bb4c4f36880c26e72a341890..f88964184903135f4354a43035a1ec6237502147 100644
--- a/src/gpu/GrYUVProvider.cpp
+++ b/src/gpu/GrYUVProvider.cpp
@@ -40,20 +40,21 @@
if (fCachedData.get()) {
planes[0] = (void*)fCachedData->data();
- planes[1] = (uint8_t*)planes[0] + (yuvInfo->fSizeInfo.fWidthBytes[SkYUVSizeInfo::kY] *
- yuvInfo->fSizeInfo.fSizes[SkYUVSizeInfo::kY].fHeight);
- planes[2] = (uint8_t*)planes[1] + (yuvInfo->fSizeInfo.fWidthBytes[SkYUVSizeInfo::kU] *
- yuvInfo->fSizeInfo.fSizes[SkYUVSizeInfo::kU].fHeight);
+ planes[1] = (uint8_t*)planes[0] + yuvInfo->fSizeInMemory[0];
+ planes[2] = (uint8_t*)planes[1] + yuvInfo->fSizeInMemory[1];
} else {
- // Fetch yuv plane sizes for memory allocation.
- if (!provider->onQueryYUV8(&yuvInfo->fSizeInfo, &yuvInfo->fColorSpace)) {
+ // Fetch yuv plane sizes for memory allocation. Here, width and height can be
+ // rounded up to JPEG block size and be larger than the image's width and height.
+ if (!provider->onGetYUVSizes(yuvInfo->fSize)) {
return false;
}
// Allocate the memory for YUV
size_t totalSize(0);
- for (int i = 0; i < 3; i++) {
- totalSize += yuvInfo->fSizeInfo.fWidthBytes[i] * yuvInfo->fSizeInfo.fSizes[i].fHeight;
+ for (int i = 0; i < GrYUVProvider::kPlaneCount; ++i) {
+ yuvInfo->fRowBytes[i] = yuvInfo->fSize[i].fWidth; // we assume snug fit: rb == width
+ yuvInfo->fSizeInMemory[i] = yuvInfo->fRowBytes[i] * yuvInfo->fSize[i].fHeight;
+ totalSize += yuvInfo->fSizeInMemory[i];
}
if (useCache) {
fCachedData.reset(SkResourceCache::NewCachedData(totalSize));
@@ -62,13 +63,12 @@
fStorage.reset(totalSize);
planes[0] = fStorage.get();
}
- planes[1] = (uint8_t*)planes[0] + (yuvInfo->fSizeInfo.fWidthBytes[SkYUVSizeInfo::kY] *
- yuvInfo->fSizeInfo.fSizes[SkYUVSizeInfo::kY].fHeight);
- planes[2] = (uint8_t*)planes[1] + (yuvInfo->fSizeInfo.fWidthBytes[SkYUVSizeInfo::kU] *
- yuvInfo->fSizeInfo.fSizes[SkYUVSizeInfo::kU].fHeight);
+ planes[1] = (uint8_t*)planes[0] + yuvInfo->fSizeInMemory[0];
+ planes[2] = (uint8_t*)planes[1] + yuvInfo->fSizeInMemory[1];
- // Get the YUV planes.
- if (!provider->onGetYUV8Planes(yuvInfo->fSizeInfo, planes)) {
+ // Get the YUV planes and update plane sizes to actual image size
+ if (!provider->onGetYUVPlanes(yuvInfo->fSize, planes, yuvInfo->fRowBytes,
+ &yuvInfo->fColorSpace)) {
return false;
}
@@ -91,21 +91,20 @@
GrSurfaceDesc yuvDesc;
yuvDesc.fConfig = kAlpha_8_GrPixelConfig;
SkAutoTUnref<GrTexture> yuvTextures[3];
- for (int i = 0; i < 3; i++) {
- yuvDesc.fWidth = yuvInfo.fSizeInfo.fSizes[i].fWidth;
- yuvDesc.fHeight = yuvInfo.fSizeInfo.fSizes[i].fHeight;
+ for (int i = 0; i < 3; ++i) {
+ yuvDesc.fWidth = yuvInfo.fSize[i].fWidth;
+ yuvDesc.fHeight = yuvInfo.fSize[i].fHeight;
// TODO: why do we need this check?
- bool needsExactTexture =
- (yuvDesc.fWidth != yuvInfo.fSizeInfo.fSizes[SkYUVSizeInfo::kY].fWidth) ||
- (yuvDesc.fHeight != yuvInfo.fSizeInfo.fSizes[SkYUVSizeInfo::kY].fHeight);
+ bool needsExactTexture = (yuvDesc.fWidth != yuvInfo.fSize[0].fWidth) ||
+ (yuvDesc.fHeight != yuvInfo.fSize[0].fHeight);
if (needsExactTexture) {
yuvTextures[i].reset(ctx->textureProvider()->createTexture(yuvDesc, SkBudgeted::kYes));
} else {
yuvTextures[i].reset(ctx->textureProvider()->createApproxTexture(yuvDesc));
}
if (!yuvTextures[i] ||
- !yuvTextures[i]->writePixels(0, 0, yuvDesc.fWidth, yuvDesc.fHeight, yuvDesc.fConfig,
- planes[i], yuvInfo.fSizeInfo.fWidthBytes[i])) {
+ !yuvTextures[i]->writePixels(0, 0, yuvDesc.fWidth, yuvDesc.fHeight,
+ yuvDesc.fConfig, planes[i], yuvInfo.fRowBytes[i])) {
return nullptr;
}
}
@@ -127,12 +126,11 @@
GrYUVEffect::CreateYUVToRGB(yuvTextures[0],
yuvTextures[1],
yuvTextures[2],
- yuvInfo.fSizeInfo.fSizes,
+ yuvInfo.fSize,
yuvInfo.fColorSpace));
paint.addColorFragmentProcessor(yuvToRgbProcessor);
paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
- const SkRect r = SkRect::MakeIWH(yuvInfo.fSizeInfo.fSizes[SkYUVSizeInfo::kY].fWidth,
- yuvInfo.fSizeInfo.fSizes[SkYUVSizeInfo::kY].fHeight);
+ const SkRect r = SkRect::MakeIWH(yuvInfo.fSize[0].fWidth, yuvInfo.fSize[0].fHeight);
SkAutoTUnref<GrDrawContext> drawContext(ctx->drawContext(renderTarget));
if (!drawContext) {
« no previous file with comments | « src/gpu/GrYUVProvider.h ('k') | src/gpu/SkGr.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698