OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright 2014 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 #ifndef GrTexturePriv_DEFINED | |
9 #define GrTexturePriv_DEFINED | |
10 | |
11 #include "GrTexture.h" | |
12 #include "SkRefCnt.h" | |
13 | |
robertphillips
2014/09/29 13:34:28
// A wrapper class that grants access to GrTexture
bsalomon
2014/09/29 18:42:11
Done.
| |
14 class GrTexturePriv : SkNoncopyable { | |
15 public: | |
16 void setFlag(GrTextureFlags flags) { | |
17 fTexture->fDesc.fFlags = fTexture->fDesc.fFlags | flags; | |
18 } | |
19 | |
20 void resetFlag(GrTextureFlags flags) { | |
21 fTexture->fDesc.fFlags = fTexture->fDesc.fFlags & ~flags; | |
22 } | |
23 | |
24 bool isSetFlag(GrTextureFlags flags) const { | |
25 return 0 != (fTexture->fDesc.fFlags & flags); | |
26 } | |
27 | |
28 void dirtyMipMaps(bool mipMapsDirty); | |
29 | |
30 bool mipMapsAreDirty() const { | |
31 return GrTexture::kValid_MipMapsStatus != fTexture->fMipMapsStatus; | |
32 } | |
33 | |
34 bool hasMipMaps() const { | |
35 return GrTexture::kNotAllocated_MipMapsStatus != fTexture->fMipMapsStatu s; | |
36 } | |
37 | |
38 static GrResourceKey ComputeKey(const GrGpu* gpu, | |
39 const GrTextureParams* params, | |
40 const GrTextureDesc& desc, | |
41 const GrCacheID& cacheID); | |
42 static GrResourceKey ComputeScratchKey(const GrTextureDesc& desc); | |
43 static bool NeedsResizing(const GrResourceKey& key); | |
44 static bool NeedsBilerp(const GrResourceKey& key); | |
45 | |
46 | |
robertphillips
2014/09/29 13:34:28
It seems like these two should be static functions
bsalomon
2014/09/29 18:42:11
Agreed, will mark as TODO.
| |
47 SkFixed normalizeFixedX(SkFixed x) const { | |
48 SkASSERT(SkIsPow2(fTexture->fDesc.fWidth)); | |
49 return x >> fTexture->fShiftFixedX; | |
50 } | |
51 | |
52 SkFixed normalizeFixedY(SkFixed y) const { | |
53 SkASSERT(SkIsPow2(fTexture->fDesc.fHeight)); | |
54 return y >> fTexture->fShiftFixedY; | |
55 } | |
56 | |
57 private: | |
58 GrTexturePriv(GrTexture* texture) : fTexture(texture) { } | |
59 | |
60 // No taking addresses of this type. | |
61 const GrTexturePriv* operator&() const; | |
62 GrTexturePriv* operator&(); | |
63 | |
64 GrTexture* fTexture; | |
65 | |
robertphillips
2014/09/29 13:34:28
// For access to ctor, ComputeScratchKey.
?
bsalomon
2014/09/29 18:42:10
first yes, CSK is already public.
| |
66 friend class GrTexture; | |
67 }; | |
68 | |
69 inline GrTexturePriv GrTexture::texturePriv() { return GrTexturePriv(this); } | |
70 | |
71 inline const GrTexturePriv GrTexture::texturePriv () const { | |
72 return GrTexturePriv(const_cast<GrTexture*>(this)); | |
73 } | |
74 | |
75 #endif | |
OLD | NEW |