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

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

Issue 1967743003: Minor GrRenderTarget retraction (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more clean up Created 4 years, 7 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/GrYUVProvider.cpp ('k') | 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 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 8
9 #include "SkGr.h" 9 #include "SkGr.h"
10 #include "SkGrPriv.h" 10 #include "SkGrPriv.h"
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 174
175 uint32_t onGetID() override { return fPR->getGenerationID(); } 175 uint32_t onGetID() override { return fPR->getGenerationID(); }
176 bool onQueryYUV8(SkYUVSizeInfo* sizeInfo, SkYUVColorSpace* colorSpace) const override { 176 bool onQueryYUV8(SkYUVSizeInfo* sizeInfo, SkYUVColorSpace* colorSpace) const override {
177 return fPR->queryYUV8(sizeInfo, colorSpace); 177 return fPR->queryYUV8(sizeInfo, colorSpace);
178 } 178 }
179 bool onGetYUV8Planes(const SkYUVSizeInfo& sizeInfo, void* planes[3]) overrid e { 179 bool onGetYUV8Planes(const SkYUVSizeInfo& sizeInfo, void* planes[3]) overrid e {
180 return fPR->getYUV8Planes(sizeInfo, planes); 180 return fPR->getYUV8Planes(sizeInfo, planes);
181 } 181 }
182 }; 182 };
183 183
184 static GrTexture* create_texture_from_yuv(GrContext* ctx, const SkBitmap& bm, 184 static sk_sp<GrTexture> create_texture_from_yuv(GrContext* ctx, const SkBitmap& bm,
185 const GrSurfaceDesc& desc) { 185 const GrSurfaceDesc& desc) {
186 // Subsets are not supported, the whole pixelRef is loaded when using YUV de coding 186 // Subsets are not supported, the whole pixelRef is loaded when using YUV de coding
187 SkPixelRef* pixelRef = bm.pixelRef(); 187 SkPixelRef* pixelRef = bm.pixelRef();
188 if ((nullptr == pixelRef) || 188 if ((nullptr == pixelRef) ||
189 (pixelRef->info().width() != bm.info().width()) || 189 (pixelRef->info().width() != bm.info().width()) ||
190 (pixelRef->info().height() != bm.info().height())) { 190 (pixelRef->info().height() != bm.info().height())) {
191 return nullptr; 191 return nullptr;
192 } 192 }
193 193
194 PixelRef_GrYUVProvider provider(pixelRef); 194 PixelRef_GrYUVProvider provider(pixelRef);
195 195
(...skipping 15 matching lines...) Expand all
211 211
212 return ctx->textureProvider()->createTexture(desc, SkBudgeted::kYes, startOf TexData, 0); 212 return ctx->textureProvider()->createTexture(desc, SkBudgeted::kYes, startOf TexData, 0);
213 } 213 }
214 214
215 GrTexture* GrUploadBitmapToTexture(GrContext* ctx, const SkBitmap& bitmap) { 215 GrTexture* GrUploadBitmapToTexture(GrContext* ctx, const SkBitmap& bitmap) {
216 GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bitmap.info(), *ctx->caps()); 216 GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bitmap.info(), *ctx->caps());
217 if (GrTexture *texture = load_etc1_texture(ctx, bitmap, desc)) { 217 if (GrTexture *texture = load_etc1_texture(ctx, bitmap, desc)) {
218 return texture; 218 return texture;
219 } 219 }
220 220
221 if (GrTexture* texture = create_texture_from_yuv(ctx, bitmap, desc)) { 221 sk_sp<GrTexture> texture(create_texture_from_yuv(ctx, bitmap, desc));
222 return texture; 222 if (texture) {
223 return texture.release();
223 } 224 }
224 225
225 SkAutoLockPixels alp(bitmap); 226 SkAutoLockPixels alp(bitmap);
226 if (!bitmap.readyToDraw()) { 227 if (!bitmap.readyToDraw()) {
227 return nullptr; 228 return nullptr;
228 } 229 }
229 SkPixmap pixmap; 230 SkPixmap pixmap;
230 if (!bitmap.peekPixels(&pixmap)) { 231 if (!bitmap.peekPixels(&pixmap)) {
231 return nullptr; 232 return nullptr;
232 } 233 }
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 GrTexture* GrGenerateMipMapsAndUploadToTexture(GrContext* ctx, const SkBitmap& b itmap) 333 GrTexture* GrGenerateMipMapsAndUploadToTexture(GrContext* ctx, const SkBitmap& b itmap)
333 { 334 {
334 GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bitmap.info(), *ctx->caps()); 335 GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bitmap.info(), *ctx->caps());
335 if (kIndex_8_SkColorType != bitmap.colorType() && !bitmap.readyToDraw()) { 336 if (kIndex_8_SkColorType != bitmap.colorType() && !bitmap.readyToDraw()) {
336 GrTexture* texture = load_etc1_texture(ctx, bitmap, desc); 337 GrTexture* texture = load_etc1_texture(ctx, bitmap, desc);
337 if (texture) { 338 if (texture) {
338 return texture; 339 return texture;
339 } 340 }
340 } 341 }
341 342
342 GrTexture* texture = create_texture_from_yuv(ctx, bitmap, desc); 343 sk_sp<GrTexture> texture(create_texture_from_yuv(ctx, bitmap, desc));
343 if (texture) { 344 if (texture) {
344 return texture; 345 return texture.release();
345 } 346 }
346 347
347 // SkMipMap::Build doesn't handle sRGB data correctly (yet). 348 // SkMipMap::Build doesn't handle sRGB data correctly (yet).
348 // Failover to the GL code-path for now. 349 // Failover to the GL code-path for now.
349 if (kLinear_SkColorProfileType != bitmap.profileType()) { 350 if (kLinear_SkColorProfileType != bitmap.profileType()) {
350 return nullptr; 351 return nullptr;
351 } 352 }
352 353
353 SkASSERT(sizeof(int) <= sizeof(uint32_t)); 354 SkASSERT(sizeof(int) <= sizeof(uint32_t));
354 if (bitmap.width() < 0 || bitmap.height() < 0) { 355 if (bitmap.width() < 0 || bitmap.height() < 0) {
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 SkErrorInternals::SetError( kInvalidPaint_SkError, 760 SkErrorInternals::SetError( kInvalidPaint_SkError,
760 "Sorry, I don't understand the filtering " 761 "Sorry, I don't understand the filtering "
761 "mode you asked for. Falling back to " 762 "mode you asked for. Falling back to "
762 "MIPMaps."); 763 "MIPMaps.");
763 textureFilterMode = GrTextureParams::kMipMap_FilterMode; 764 textureFilterMode = GrTextureParams::kMipMap_FilterMode;
764 break; 765 break;
765 766
766 } 767 }
767 return textureFilterMode; 768 return textureFilterMode;
768 } 769 }
OLDNEW
« no previous file with comments | « src/gpu/GrYUVProvider.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698