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 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 327 |
| 328 SkImage* SkImageTextureData::newImage(GrContext* context, SkBudgeted budgeted) c
onst { |
| 329 if (context->uniqueID() != fContextUniqueID) { |
| 330 return nullptr; |
| 331 } |
| 332 SkPixmap pixmap; |
| 333 fPixmapGenerator(&pixmap); |
| 334 return SkImage::NewTextureFromPixmap(context, pixmap, budgeted); |
| 335 } |
| 336 |
313 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 337 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
314 | 338 |
315 GrTexture* GrDeepCopyTexture(GrTexture* src, SkBudgeted budgeted) { | 339 GrTexture* GrDeepCopyTexture(GrTexture* src, SkBudgeted budgeted) { |
316 GrContext* ctx = src->getContext(); | 340 GrContext* ctx = src->getContext(); |
317 | 341 |
318 GrSurfaceDesc desc = src->desc(); | 342 GrSurfaceDesc desc = src->desc(); |
319 GrTexture* dst = ctx->textureProvider()->createTexture(desc, budgeted, nullp
tr, 0); | 343 GrTexture* dst = ctx->textureProvider()->createTexture(desc, budgeted, nullp
tr, 0); |
320 if (!dst) { | 344 if (!dst) { |
321 return nullptr; | 345 return nullptr; |
322 } | 346 } |
323 | 347 |
324 const SkIRect srcR = SkIRect::MakeWH(desc.fWidth, desc.fHeight); | 348 const SkIRect srcR = SkIRect::MakeWH(desc.fWidth, desc.fHeight); |
325 const SkIPoint dstP = SkIPoint::Make(0, 0); | 349 const SkIPoint dstP = SkIPoint::Make(0, 0); |
326 ctx->copySurface(dst, src, srcR, dstP); | 350 ctx->copySurface(dst, src, srcR, dstP); |
327 ctx->flushSurfaceWrites(dst); | 351 ctx->flushSurfaceWrites(dst); |
328 return dst; | 352 return dst; |
329 } | 353 } |
330 | 354 |
OLD | NEW |