OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright 2015 Google Inc. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license that can be | |
5 * found in the LICENSE file. | |
6 */ | |
7 | |
8 #include "GrImageIDTextureAdjuster.h" | |
9 | |
10 #include "SkBitmap.h" | |
11 #include "SkGrPriv.h" | |
12 #include "SkImage_Base.h" | |
13 | |
14 | |
15 GrBitmapTextureAdjuster::GrBitmapTextureAdjuster(const SkBitmap* bmp) | |
16 : INHERITED(bmp->getTexture(), SkIRect::MakeWH(bmp->width(), bmp->height())) | |
17 , fBmp(bmp) {} | |
18 | |
19 void GrBitmapTextureAdjuster::makeCopyKey(const CopyParams& params, GrUniqueKey* copyKey) { | |
20 if (fBmp->isVolatile()) { | |
21 return; | |
22 } | |
23 // The content area must represent the whole bitmap. Texture-backed bitmaps don't support | |
24 // extractSubset(). Therefore, either the bitmap and the texture are the sam e size or the | |
25 // content's dimensions are the bitmap's dimensions which is pinned to the u pper left | |
26 // of the texture. | |
27 GrUniqueKey baseKey; | |
28 GrMakeKeyFromImageID(&baseKey, fBmp->getGenerationID(), | |
robertphillips
2015/11/05 20:13:24
align ?
bsalomon
2015/11/06 15:24:25
Done.
| |
29 SkIRect::MakeWH(fBmp->width(), fBmp->height())); | |
30 MakeCopyKeyFromOrigKey(baseKey, params, copyKey); | |
31 } | |
32 | |
33 void GrBitmapTextureAdjuster::didCacheCopy(const GrUniqueKey& copyKey) { | |
34 GrInstallBitmapUniqueKeyInvalidator(copyKey, fBmp->pixelRef()); | |
35 } | |
36 | |
37 ////////////////////////////////////////////////////////////////////////////// | |
38 | |
39 GrImageTextureAdjuster::GrImageTextureAdjuster(const SkImage_Base* img) | |
40 : INHERITED(img->peekTexture(), SkIRect::MakeWH(img->width(), img->height()) ) | |
41 , fImageBase(img) {} | |
42 | |
43 void GrImageTextureAdjuster::makeCopyKey(const CopyParams& params, GrUniqueKey* copyKey) { | |
44 // By construction this texture adjuster always represents an entire SkImage , so use the | |
45 // image's width and height for the key's rectangle. | |
46 GrUniqueKey baseKey; | |
47 GrMakeKeyFromImageID(&baseKey, fImageBase->uniqueID(), | |
48 SkIRect::MakeWH(fImageBase->width(), fImageBase->height ())); | |
49 MakeCopyKeyFromOrigKey(baseKey, params, copyKey); | |
50 } | |
51 | |
52 void GrImageTextureAdjuster::didCacheCopy(const GrUniqueKey& copyKey) { | |
53 // We don't currently have a mechanism for notifications on Images! | |
54 } | |
OLD | NEW |