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" |
11 #include "GrGpuResourcePriv.h" | 11 #include "GrGpuResourcePriv.h" |
12 #include "SkBitmap.h" | 12 #include "SkBitmap.h" |
13 #include "SkGrPriv.h" | 13 #include "SkGrPriv.h" |
14 #include "SkImage_Base.h" | 14 #include "SkImage_Base.h" |
| 15 #include "SkImageCacherator.h" |
15 #include "SkPixelRef.h" | 16 #include "SkPixelRef.h" |
16 | 17 |
17 GrBitmapTextureAdjuster::GrBitmapTextureAdjuster(const SkBitmap* bmp) | 18 GrBitmapTextureAdjuster::GrBitmapTextureAdjuster(const SkBitmap* bmp) |
18 : INHERITED(bmp->getTexture(), SkIRect::MakeWH(bmp->width(), bmp->height())) | 19 : INHERITED(bmp->getTexture(), SkIRect::MakeWH(bmp->width(), bmp->height())) |
19 , fBmp(bmp) {} | 20 , fBmp(bmp) {} |
20 | 21 |
21 void GrBitmapTextureAdjuster::makeCopyKey(const CopyParams& params, GrUniqueKey*
copyKey) { | 22 void GrBitmapTextureAdjuster::makeCopyKey(const CopyParams& params, GrUniqueKey*
copyKey) { |
22 if (fBmp->isVolatile()) { | 23 if (fBmp->isVolatile()) { |
23 return; | 24 return; |
24 } | 25 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 | 90 |
90 void GrBitmapTextureMaker::makeCopyKey(const CopyParams& copyParams, GrUniqueKey
* copyKey) { | 91 void GrBitmapTextureMaker::makeCopyKey(const CopyParams& copyParams, GrUniqueKey
* copyKey) { |
91 if (fOriginalKey.isValid()) { | 92 if (fOriginalKey.isValid()) { |
92 MakeCopyKeyFromOrigKey(fOriginalKey, copyParams, copyKey); | 93 MakeCopyKeyFromOrigKey(fOriginalKey, copyParams, copyKey); |
93 } | 94 } |
94 } | 95 } |
95 | 96 |
96 void GrBitmapTextureMaker::didCacheCopy(const GrUniqueKey& copyKey) { | 97 void GrBitmapTextureMaker::didCacheCopy(const GrUniqueKey& copyKey) { |
97 GrInstallBitmapUniqueKeyInvalidator(copyKey, fBitmap.pixelRef()); | 98 GrInstallBitmapUniqueKeyInvalidator(copyKey, fBitmap.pixelRef()); |
98 } | 99 } |
| 100 |
| 101 ////////////////////////////////////////////////////////////////////////////// |
| 102 |
| 103 GrImageTextureMaker::GrImageTextureMaker(GrContext* context, SkImageCacherator*
cacher, |
| 104 const SkImage* client, SkImage::Caching
Hint chint) |
| 105 : INHERITED(context, cacher->info().width(), cacher->info().height()) |
| 106 , fCacher(cacher) |
| 107 , fClient(client) |
| 108 , fCachingHint(chint) { |
| 109 if (client) { |
| 110 GrMakeKeyFromImageID(&fOriginalKey, client->uniqueID(), |
| 111 SkIRect::MakeWH(this->width(), this->height())); |
| 112 } |
| 113 } |
| 114 |
| 115 GrTexture* GrImageTextureMaker::refOriginalTexture() { |
| 116 return fCacher->lockTexture(this->context(), fOriginalKey, fClient, fCaching
Hint); |
| 117 } |
| 118 |
| 119 void GrImageTextureMaker::makeCopyKey(const CopyParams& stretch, GrUniqueKey* pa
ramsCopyKey) { |
| 120 if (fOriginalKey.isValid() && SkImage::kAllow_CachingHint == fCachingHint) { |
| 121 MakeCopyKeyFromOrigKey(fOriginalKey, stretch, paramsCopyKey); |
| 122 } |
| 123 } |
| 124 |
| 125 void GrImageTextureMaker::didCacheCopy(const GrUniqueKey& copyKey) { |
| 126 if (fClient) { |
| 127 as_IB(fClient)->notifyAddedToCache(); |
| 128 } |
| 129 } |
OLD | NEW |