| OLD | NEW |
| 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 Loading... |
| 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 | |
| 326 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 313 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 327 | 314 |
| 328 GrTexture* GrDeepCopyTexture(GrTexture* src, SkBudgeted budgeted) { | 315 GrTexture* GrDeepCopyTexture(GrTexture* src, SkBudgeted budgeted) { |
| 329 GrContext* ctx = src->getContext(); | 316 GrContext* ctx = src->getContext(); |
| 330 | 317 |
| 331 GrSurfaceDesc desc = src->desc(); | 318 GrSurfaceDesc desc = src->desc(); |
| 332 GrTexture* dst = ctx->textureProvider()->createTexture(desc, budgeted, nullp
tr, 0); | 319 GrTexture* dst = ctx->textureProvider()->createTexture(desc, budgeted, nullp
tr, 0); |
| 333 if (!dst) { | 320 if (!dst) { |
| 334 return nullptr; | 321 return nullptr; |
| 335 } | 322 } |
| 336 | 323 |
| 337 const SkIRect srcR = SkIRect::MakeWH(desc.fWidth, desc.fHeight); | 324 const SkIRect srcR = SkIRect::MakeWH(desc.fWidth, desc.fHeight); |
| 338 const SkIPoint dstP = SkIPoint::Make(0, 0); | 325 const SkIPoint dstP = SkIPoint::Make(0, 0); |
| 339 ctx->copySurface(dst, src, srcR, dstP); | 326 ctx->copySurface(dst, src, srcR, dstP); |
| 340 ctx->flushSurfaceWrites(dst); | 327 ctx->flushSurfaceWrites(dst); |
| 341 return dst; | 328 return dst; |
| 342 } | 329 } |
| 343 | 330 |
| OLD | NEW |