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

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

Issue 1734043002: Revert of Move Budgeted enum out of SkSurface, use in GrTextureProvider (Closed) Base URL: https://skia.googlesource.com/skia.git@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 | « src/gpu/GrTextureProvider.cpp ('k') | src/gpu/SkGpuDevice.h » ('j') | 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 2015 Google Inc. 2 * Copyright 2015 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 "GrContext.h" 8 #include "GrContext.h"
9 #include "GrDrawContext.h" 9 #include "GrDrawContext.h"
10 #include "GrYUVProvider.h" 10 #include "GrYUVProvider.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 GrSurfaceDesc yuvDesc; 91 GrSurfaceDesc yuvDesc;
92 yuvDesc.fConfig = kAlpha_8_GrPixelConfig; 92 yuvDesc.fConfig = kAlpha_8_GrPixelConfig;
93 SkAutoTUnref<GrTexture> yuvTextures[3]; 93 SkAutoTUnref<GrTexture> yuvTextures[3];
94 for (int i = 0; i < 3; ++i) { 94 for (int i = 0; i < 3; ++i) {
95 yuvDesc.fWidth = yuvInfo.fSize[i].fWidth; 95 yuvDesc.fWidth = yuvInfo.fSize[i].fWidth;
96 yuvDesc.fHeight = yuvInfo.fSize[i].fHeight; 96 yuvDesc.fHeight = yuvInfo.fSize[i].fHeight;
97 // TODO: why do we need this check? 97 // TODO: why do we need this check?
98 bool needsExactTexture = (yuvDesc.fWidth != yuvInfo.fSize[0].fWidth) || 98 bool needsExactTexture = (yuvDesc.fWidth != yuvInfo.fSize[0].fWidth) ||
99 (yuvDesc.fHeight != yuvInfo.fSize[0].fHeight); 99 (yuvDesc.fHeight != yuvInfo.fSize[0].fHeight);
100 if (needsExactTexture) { 100 if (needsExactTexture) {
101 yuvTextures[i].reset(ctx->textureProvider()->createTexture(yuvDesc, SkBudgeted::kYes)); 101 yuvTextures[i].reset(ctx->textureProvider()->createTexture(yuvDesc, true));
102 } else { 102 } else {
103 yuvTextures[i].reset(ctx->textureProvider()->createApproxTexture(yuv Desc)); 103 yuvTextures[i].reset(ctx->textureProvider()->createApproxTexture(yuv Desc));
104 } 104 }
105 if (!yuvTextures[i] || 105 if (!yuvTextures[i] ||
106 !yuvTextures[i]->writePixels(0, 0, yuvDesc.fWidth, yuvDesc.fHeight, 106 !yuvTextures[i]->writePixels(0, 0, yuvDesc.fWidth, yuvDesc.fHeight,
107 yuvDesc.fConfig, planes[i], yuvInfo.fRo wBytes[i])) { 107 yuvDesc.fConfig, planes[i], yuvInfo.fRo wBytes[i])) {
108 return nullptr; 108 return nullptr;
109 } 109 }
110 } 110 }
111 111
112 GrSurfaceDesc rtDesc = desc; 112 GrSurfaceDesc rtDesc = desc;
113 rtDesc.fFlags = rtDesc.fFlags | kRenderTarget_GrSurfaceFlag; 113 rtDesc.fFlags = rtDesc.fFlags | kRenderTarget_GrSurfaceFlag;
114 114
115 SkAutoTUnref<GrTexture> result(ctx->textureProvider()->createTexture(rtDesc, SkBudgeted::kYes, 115 SkAutoTUnref<GrTexture> result(ctx->textureProvider()->createTexture(rtDesc, true, nullptr, 0));
116 nullptr , 0));
117 if (!result) { 116 if (!result) {
118 return nullptr; 117 return nullptr;
119 } 118 }
120 119
121 GrRenderTarget* renderTarget = result->asRenderTarget(); 120 GrRenderTarget* renderTarget = result->asRenderTarget();
122 SkASSERT(renderTarget); 121 SkASSERT(renderTarget);
123 122
124 GrPaint paint; 123 GrPaint paint;
125 SkAutoTUnref<const GrFragmentProcessor> yuvToRgbProcessor( 124 SkAutoTUnref<const GrFragmentProcessor> yuvToRgbProcessor(
126 GrYUVEffect::CreateYUVToRGB(yuvTextures[ 0], 125 GrYUVEffect::CreateYUVToRGB(yuvTextures[ 0],
127 yuvTextures[ 1], 126 yuvTextures[ 1],
128 yuvTextures[ 2], 127 yuvTextures[ 2],
129 yuvInfo.fSiz e, 128 yuvInfo.fSiz e,
130 yuvInfo.fCol orSpace)); 129 yuvInfo.fCol orSpace));
131 paint.addColorFragmentProcessor(yuvToRgbProcessor); 130 paint.addColorFragmentProcessor(yuvToRgbProcessor);
132 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode); 131 paint.setPorterDuffXPFactory(SkXfermode::kSrc_Mode);
133 const SkRect r = SkRect::MakeIWH(yuvInfo.fSize[0].fWidth, yuvInfo.fSize[0].f Height); 132 const SkRect r = SkRect::MakeIWH(yuvInfo.fSize[0].fWidth, yuvInfo.fSize[0].f Height);
134 133
135 SkAutoTUnref<GrDrawContext> drawContext(ctx->drawContext(renderTarget)); 134 SkAutoTUnref<GrDrawContext> drawContext(ctx->drawContext(renderTarget));
136 if (!drawContext) { 135 if (!drawContext) {
137 return nullptr; 136 return nullptr;
138 } 137 }
139 138
140 drawContext->drawRect(GrClip::WideOpen(), paint, SkMatrix::I(), r); 139 drawContext->drawRect(GrClip::WideOpen(), paint, SkMatrix::I(), r);
141 140
142 return result.detach(); 141 return result.detach();
143 } 142 }
144 143
OLDNEW
« no previous file with comments | « src/gpu/GrTextureProvider.cpp ('k') | src/gpu/SkGpuDevice.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698