| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "GrImageIDTextureAdjuster.h" | 8 #include "GrImageIDTextureAdjuster.h" |
| 9 | 9 |
| 10 #include "GrContext.h" | 10 #include "GrContext.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 , fBitmap(bitmap) { | 74 , fBitmap(bitmap) { |
| 75 SkASSERT(!bitmap.getTexture()); | 75 SkASSERT(!bitmap.getTexture()); |
| 76 if (!bitmap.isVolatile()) { | 76 if (!bitmap.isVolatile()) { |
| 77 SkIPoint origin = bitmap.pixelRefOrigin(); | 77 SkIPoint origin = bitmap.pixelRefOrigin(); |
| 78 SkIRect subset = SkIRect::MakeXYWH(origin.fX, origin.fY, bitmap.width(), | 78 SkIRect subset = SkIRect::MakeXYWH(origin.fX, origin.fY, bitmap.width(), |
| 79 bitmap.height()); | 79 bitmap.height()); |
| 80 GrMakeKeyFromImageID(&fOriginalKey, bitmap.pixelRef()->getGenerationID()
, subset); | 80 GrMakeKeyFromImageID(&fOriginalKey, bitmap.pixelRef()->getGenerationID()
, subset); |
| 81 } | 81 } |
| 82 } | 82 } |
| 83 | 83 |
| 84 GrTexture* GrBitmapTextureMaker::refOriginalTexture(bool willBeMipped) { | 84 GrTexture* GrBitmapTextureMaker::refOriginalTexture(bool willBeMipped, bool gamm
aCorrect) { |
| 85 GrTexture* tex = nullptr; | 85 GrTexture* tex = nullptr; |
| 86 | 86 |
| 87 if (fOriginalKey.isValid()) { | 87 if (fOriginalKey.isValid()) { |
| 88 tex = this->context()->textureProvider()->findAndRefTextureByUniqueKey(f
OriginalKey); | 88 tex = this->context()->textureProvider()->findAndRefTextureByUniqueKey(f
OriginalKey); |
| 89 if (tex) { | 89 if (tex) { |
| 90 return tex; | 90 return tex; |
| 91 } | 91 } |
| 92 } | 92 } |
| 93 if (willBeMipped) { | 93 if (willBeMipped) { |
| 94 tex = GrGenerateMipMapsAndUploadToTexture(this->context(), fBitmap); | 94 tex = GrGenerateMipMapsAndUploadToTexture(this->context(), fBitmap, gamm
aCorrect); |
| 95 } | 95 } |
| 96 if (!tex) { | 96 if (!tex) { |
| 97 tex = GrUploadBitmapToTexture(this->context(), fBitmap); | 97 tex = GrUploadBitmapToTexture(this->context(), fBitmap); |
| 98 } | 98 } |
| 99 if (tex && fOriginalKey.isValid()) { | 99 if (tex && fOriginalKey.isValid()) { |
| 100 tex->resourcePriv().setUniqueKey(fOriginalKey); | 100 tex->resourcePriv().setUniqueKey(fOriginalKey); |
| 101 GrInstallBitmapUniqueKeyInvalidator(fOriginalKey, fBitmap.pixelRef()); | 101 GrInstallBitmapUniqueKeyInvalidator(fOriginalKey, fBitmap.pixelRef()); |
| 102 } | 102 } |
| 103 return tex; | 103 return tex; |
| 104 } | 104 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 123 cacher_is_alpha_only(*cacher)) | 123 cacher_is_alpha_only(*cacher)) |
| 124 , fCacher(cacher) | 124 , fCacher(cacher) |
| 125 , fClient(client) | 125 , fClient(client) |
| 126 , fCachingHint(chint) { | 126 , fCachingHint(chint) { |
| 127 if (client) { | 127 if (client) { |
| 128 GrMakeKeyFromImageID(&fOriginalKey, client->uniqueID(), | 128 GrMakeKeyFromImageID(&fOriginalKey, client->uniqueID(), |
| 129 SkIRect::MakeWH(this->width(), this->height())); | 129 SkIRect::MakeWH(this->width(), this->height())); |
| 130 } | 130 } |
| 131 } | 131 } |
| 132 | 132 |
| 133 GrTexture* GrImageTextureMaker::refOriginalTexture(bool willBeMipped) { | 133 GrTexture* GrImageTextureMaker::refOriginalTexture(bool willBeMipped, bool gamma
Correct) { |
| 134 return fCacher->lockTexture(this->context(), fOriginalKey, fClient, fCaching
Hint, willBeMipped); | 134 return fCacher->lockTexture(this->context(), fOriginalKey, fClient, fCaching
Hint, willBeMipped, |
| 135 gammaCorrect); |
| 135 } | 136 } |
| 136 | 137 |
| 137 void GrImageTextureMaker::makeCopyKey(const CopyParams& stretch, GrUniqueKey* pa
ramsCopyKey) { | 138 void GrImageTextureMaker::makeCopyKey(const CopyParams& stretch, GrUniqueKey* pa
ramsCopyKey) { |
| 138 if (fOriginalKey.isValid() && SkImage::kAllow_CachingHint == fCachingHint) { | 139 if (fOriginalKey.isValid() && SkImage::kAllow_CachingHint == fCachingHint) { |
| 139 MakeCopyKeyFromOrigKey(fOriginalKey, stretch, paramsCopyKey); | 140 MakeCopyKeyFromOrigKey(fOriginalKey, stretch, paramsCopyKey); |
| 140 } | 141 } |
| 141 } | 142 } |
| 142 | 143 |
| 143 void GrImageTextureMaker::didCacheCopy(const GrUniqueKey& copyKey) { | 144 void GrImageTextureMaker::didCacheCopy(const GrUniqueKey& copyKey) { |
| 144 if (fClient) { | 145 if (fClient) { |
| 145 as_IB(fClient)->notifyAddedToCache(); | 146 as_IB(fClient)->notifyAddedToCache(); |
| 146 } | 147 } |
| 147 } | 148 } |
| OLD | NEW |