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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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) { |
85 GrTexture* tex; | 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 // disable mipmapping until we generate anisotropic mipmap levels | |
94 willBeMipped = false; | |
95 if (willBeMipped) { | 93 if (willBeMipped) { |
96 tex = GrGenerateMipMapsAndUploadToTexture(this->context(), fBitmap); | 94 tex = GrGenerateMipMapsAndUploadToTexture(this->context(), fBitmap); |
97 } else { | 95 } |
| 96 if (!tex) { |
98 tex = GrUploadBitmapToTexture(this->context(), fBitmap); | 97 tex = GrUploadBitmapToTexture(this->context(), fBitmap); |
99 } | 98 } |
100 if (tex && fOriginalKey.isValid()) { | 99 if (tex && fOriginalKey.isValid()) { |
101 tex->resourcePriv().setUniqueKey(fOriginalKey); | 100 tex->resourcePriv().setUniqueKey(fOriginalKey); |
102 GrInstallBitmapUniqueKeyInvalidator(fOriginalKey, fBitmap.pixelRef()); | 101 GrInstallBitmapUniqueKeyInvalidator(fOriginalKey, fBitmap.pixelRef()); |
103 } | 102 } |
104 return tex; | 103 return tex; |
105 } | 104 } |
106 | 105 |
107 void GrBitmapTextureMaker::makeCopyKey(const CopyParams& copyParams, GrUniqueKey
* copyKey) { | 106 void GrBitmapTextureMaker::makeCopyKey(const CopyParams& copyParams, GrUniqueKey
* copyKey) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 if (fOriginalKey.isValid() && SkImage::kAllow_CachingHint == fCachingHint) { | 138 if (fOriginalKey.isValid() && SkImage::kAllow_CachingHint == fCachingHint) { |
140 MakeCopyKeyFromOrigKey(fOriginalKey, stretch, paramsCopyKey); | 139 MakeCopyKeyFromOrigKey(fOriginalKey, stretch, paramsCopyKey); |
141 } | 140 } |
142 } | 141 } |
143 | 142 |
144 void GrImageTextureMaker::didCacheCopy(const GrUniqueKey& copyKey) { | 143 void GrImageTextureMaker::didCacheCopy(const GrUniqueKey& copyKey) { |
145 if (fClient) { | 144 if (fClient) { |
146 as_IB(fClient)->notifyAddedToCache(); | 145 as_IB(fClient)->notifyAddedToCache(); |
147 } | 146 } |
148 } | 147 } |
OLD | NEW |