| 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 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 info = pixmap.info(); | 433 info = pixmap.info(); |
| 434 pixelSize = SkAlign8(pixmap.getSafeSize()); | 434 pixelSize = SkAlign8(pixmap.getSafeSize()); |
| 435 if (pixmap.ctable()) { | 435 if (pixmap.ctable()) { |
| 436 ctCount = pixmap.ctable()->count(); | 436 ctCount = pixmap.ctable()->count(); |
| 437 ctSize = SkAlign8(pixmap.ctable()->count() * 4); | 437 ctSize = SkAlign8(pixmap.ctable()->count() * 4); |
| 438 } | 438 } |
| 439 } else { | 439 } else { |
| 440 // Here we're just using presence of data to know whether there is a cod
ec behind the image. | 440 // Here we're just using presence of data to know whether there is a cod
ec behind the image. |
| 441 // In the future we will access the cacherator and get the exact data th
at we want to (e.g. | 441 // In the future we will access the cacherator and get the exact data th
at we want to (e.g. |
| 442 // yuv planes) upload. | 442 // yuv planes) upload. |
| 443 SkAutoTUnref<SkData> data(this->refEncoded()); | 443 sk_sp<SkData> data(this->refEncoded()); |
| 444 if (!data && !this->peekPixels(nullptr)) { | 444 if (!data && !this->peekPixels(nullptr)) { |
| 445 return 0; | 445 return 0; |
| 446 } | 446 } |
| 447 SkAlphaType at = this->isOpaque() ? kOpaque_SkAlphaType : kPremul_SkAlph
aType; | 447 SkAlphaType at = this->isOpaque() ? kOpaque_SkAlphaType : kPremul_SkAlph
aType; |
| 448 info = SkImageInfo::MakeN32(scaledSize.width(), scaledSize.height(), at)
; | 448 info = SkImageInfo::MakeN32(scaledSize.width(), scaledSize.height(), at)
; |
| 449 pixelSize = SkAlign8(SkAutoPixmapStorage::AllocSize(info, nullptr)); | 449 pixelSize = SkAlign8(SkAutoPixmapStorage::AllocSize(info, nullptr)); |
| 450 if (fillMode) { | 450 if (fillMode) { |
| 451 pixmap.alloc(info); | 451 pixmap.alloc(info); |
| 452 if (isScaled) { | 452 if (isScaled) { |
| 453 if (!this->scalePixels(pixmap, scaleFilterQuality, | 453 if (!this->scalePixels(pixmap, scaleFilterQuality, |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 return nullptr; | 570 return nullptr; |
| 571 } | 571 } |
| 572 SkAutoTUnref<GrTexture> texture(GrUploadMipMapToTexture(ctx, info, texels, m
ipLevelCount)); | 572 SkAutoTUnref<GrTexture> texture(GrUploadMipMapToTexture(ctx, info, texels, m
ipLevelCount)); |
| 573 if (!texture) { | 573 if (!texture) { |
| 574 return nullptr; | 574 return nullptr; |
| 575 } | 575 } |
| 576 return sk_make_sp<SkImage_Gpu>(texture->width(), texture->height(), kNeedNew
ImageUniqueID, | 576 return sk_make_sp<SkImage_Gpu>(texture->width(), texture->height(), kNeedNew
ImageUniqueID, |
| 577 info.alphaType(), texture, sk_ref_sp(info.col
orSpace()), | 577 info.alphaType(), texture, sk_ref_sp(info.col
orSpace()), |
| 578 budgeted); | 578 budgeted); |
| 579 } | 579 } |
| OLD | NEW |