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

Side by Side Diff: src/image/SkImage_Gpu.cpp

Issue 1776913003: Add SkImage::NewTextureFromPixmap (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: try again 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 unified diff | Download patch
« no previous file with comments | « src/image/SkImage.cpp ('k') | tests/ImageTest.cpp » ('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 2012 Google Inc. 2 * Copyright 2012 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 "GrCaps.h" 8 #include "GrCaps.h"
9 #include "GrContext.h" 9 #include "GrContext.h"
10 #include "GrDrawContext.h" 10 #include "GrDrawContext.h"
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 return create_image_from_maker(&maker, at, this->uniqueID()); 303 return create_image_from_maker(&maker, at, this->uniqueID());
304 } 304 }
305 SkBitmap bmp; 305 SkBitmap bmp;
306 if (!this->asLegacyBitmap(&bmp, kRO_LegacyBitmapMode)) { 306 if (!this->asLegacyBitmap(&bmp, kRO_LegacyBitmapMode)) {
307 return nullptr; 307 return nullptr;
308 } 308 }
309 GrBitmapTextureMaker maker(context, bmp); 309 GrBitmapTextureMaker maker(context, bmp);
310 return create_image_from_maker(&maker, at, this->uniqueID()); 310 return create_image_from_maker(&maker, at, this->uniqueID());
311 } 311 }
312 312
313 SkImage* SkImage::NewTextureFromPixmap(GrContext* ctx, const SkPixmap& pixmap,
314 SkBudgeted budgeted) {
315 if (!ctx) {
316 return nullptr;
317 }
318 SkAutoTUnref<GrTexture> texture(GrUploadPixmapToTexture(ctx, pixmap));
319 if (!texture) {
320 return nullptr;
321 }
322 return new SkImage_Gpu(texture->width(), texture->height(), kNeedNewImageUni queID,
323 pixmap.alphaType(), texture, budgeted);
324 }
325
313 //////////////////////////////////////////////////////////////////////////////// /////////////////// 326 //////////////////////////////////////////////////////////////////////////////// ///////////////////
314 327
315 GrTexture* GrDeepCopyTexture(GrTexture* src, SkBudgeted budgeted) { 328 GrTexture* GrDeepCopyTexture(GrTexture* src, SkBudgeted budgeted) {
316 GrContext* ctx = src->getContext(); 329 GrContext* ctx = src->getContext();
317 330
318 GrSurfaceDesc desc = src->desc(); 331 GrSurfaceDesc desc = src->desc();
319 GrTexture* dst = ctx->textureProvider()->createTexture(desc, budgeted, nullp tr, 0); 332 GrTexture* dst = ctx->textureProvider()->createTexture(desc, budgeted, nullp tr, 0);
320 if (!dst) { 333 if (!dst) {
321 return nullptr; 334 return nullptr;
322 } 335 }
323 336
324 const SkIRect srcR = SkIRect::MakeWH(desc.fWidth, desc.fHeight); 337 const SkIRect srcR = SkIRect::MakeWH(desc.fWidth, desc.fHeight);
325 const SkIPoint dstP = SkIPoint::Make(0, 0); 338 const SkIPoint dstP = SkIPoint::Make(0, 0);
326 ctx->copySurface(dst, src, srcR, dstP); 339 ctx->copySurface(dst, src, srcR, dstP);
327 ctx->flushSurfaceWrites(dst); 340 ctx->flushSurfaceWrites(dst);
328 return dst; 341 return dst;
329 } 342 }
330 343
OLDNEW
« no previous file with comments | « src/image/SkImage.cpp ('k') | tests/ImageTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698