| 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 "SkAutoPixmapStorage.h" | 8 #include "SkAutoPixmapStorage.h" |
| 9 #include "GrCaps.h" | 9 #include "GrCaps.h" |
| 10 #include "GrContext.h" | 10 #include "GrContext.h" |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 return nullptr; | 313 return nullptr; |
| 314 } | 314 } |
| 315 SkAutoTUnref<GrTexture> texture(GrUploadPixmapToTexture(ctx, pixmap, budgete
d)); | 315 SkAutoTUnref<GrTexture> texture(GrUploadPixmapToTexture(ctx, pixmap, budgete
d)); |
| 316 if (!texture) { | 316 if (!texture) { |
| 317 return nullptr; | 317 return nullptr; |
| 318 } | 318 } |
| 319 return sk_make_sp<SkImage_Gpu>(texture->width(), texture->height(), kNeedNew
ImageUniqueID, | 319 return sk_make_sp<SkImage_Gpu>(texture->width(), texture->height(), kNeedNew
ImageUniqueID, |
| 320 pixmap.alphaType(), texture, budgeted); | 320 pixmap.alphaType(), texture, budgeted); |
| 321 } | 321 } |
| 322 | 322 |
| 323 sk_sp<SkImage> SkImage::MakeTextureFromMipMap(GrContext* ctx, const SkImageInfo&
info, |
| 324 const GrMipLevel* texels, int mipL
evelCount, |
| 325 SkBudgeted budgeted) { |
| 326 if (!ctx) { |
| 327 return nullptr; |
| 328 } |
| 329 SkAutoTUnref<GrTexture> texture(GrUploadMipMapToTexture(ctx, info, texels, m
ipLevelCount)); |
| 330 if (!texture) { |
| 331 return nullptr; |
| 332 } |
| 333 return sk_make_sp<SkImage_Gpu>(texture->width(), texture->height(), kNeedNew
ImageUniqueID, |
| 334 info.alphaType(), texture, budgeted); |
| 335 } |
| 336 |
| 323 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 337 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 324 | 338 |
| 325 class DeferredTextureImage { | 339 class DeferredTextureImage { |
| 326 public: | 340 public: |
| 327 SkImage* newImage(GrContext* context, SkBudgeted) const; | 341 SkImage* newImage(GrContext* context, SkBudgeted) const; |
| 328 | 342 |
| 329 private: | 343 private: |
| 330 uint32_t fContextUniqueID; | 344 uint32_t fContextUniqueID; |
| 331 struct MipMapLevelData { | 345 struct MipMapLevelData { |
| 332 void* fPixelData; | 346 void* fPixelData; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 return nullptr; | 475 return nullptr; |
| 462 } | 476 } |
| 463 | 477 |
| 464 const SkIRect srcR = SkIRect::MakeWH(desc.fWidth, desc.fHeight); | 478 const SkIRect srcR = SkIRect::MakeWH(desc.fWidth, desc.fHeight); |
| 465 const SkIPoint dstP = SkIPoint::Make(0, 0); | 479 const SkIPoint dstP = SkIPoint::Make(0, 0); |
| 466 ctx->copySurface(dst, src, srcR, dstP); | 480 ctx->copySurface(dst, src, srcR, dstP); |
| 467 ctx->flushSurfaceWrites(dst); | 481 ctx->flushSurfaceWrites(dst); |
| 468 return dst; | 482 return dst; |
| 469 } | 483 } |
| 470 | 484 |
| OLD | NEW |