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 |
| 14 /** Class that adds methods to GrTexture that are only intended for use internal
to Skia. |
| 15 This class is purely a privileged window into GrTexture. It should never hav
e additional data |
| 16 members or virtual methods. |
| 17 Non-static methods that are not trivial inlines should be spring-boarded (e.
g. declared and |
| 18 implemented privately in GrTexture with a inline public method here). */ |
| 19 class GrTexturePriv : SkNoncopyable { |
| 20 public: |
| 21 void setFlag(GrTextureFlags flags) { |
| 22 fTexture->fDesc.fFlags = fTexture->fDesc.fFlags | flags; |
| 23 } |
| 24 |
| 25 void resetFlag(GrTextureFlags flags) { |
| 26 fTexture->fDesc.fFlags = fTexture->fDesc.fFlags & ~flags; |
| 27 } |
| 28 |
| 29 bool isSetFlag(GrTextureFlags flags) const { |
| 30 return 0 != (fTexture->fDesc.fFlags & flags); |
| 31 } |
| 32 |
| 33 void dirtyMipMaps(bool mipMapsDirty) { fTexture->dirtyMipMaps(mipMapsDirty);
} |
| 34 |
| 35 bool mipMapsAreDirty() const { |
| 36 return GrTexture::kValid_MipMapsStatus != fTexture->fMipMapsStatus; |
| 37 } |
| 38 |
| 39 bool hasMipMaps() const { |
| 40 return GrTexture::kNotAllocated_MipMapsStatus != fTexture->fMipMapsStatu
s; |
| 41 } |
| 42 |
| 43 static GrResourceKey ComputeKey(const GrGpu* gpu, |
| 44 const GrTextureParams* params, |
| 45 const GrTextureDesc& desc, |
| 46 const GrCacheID& cacheID); |
| 47 static GrResourceKey ComputeScratchKey(const GrTextureDesc& desc); |
| 48 static bool NeedsResizing(const GrResourceKey& key); |
| 49 static bool NeedsBilerp(const GrResourceKey& key); |
| 50 |
| 51 |
| 52 // TODO: Move this logic and the shift values out of here and to the callers
. |
| 53 SkFixed normalizeFixedX(SkFixed x) const { |
| 54 SkASSERT(SkIsPow2(fTexture->fDesc.fWidth)); |
| 55 return x >> fTexture->fShiftFixedX; |
| 56 } |
| 57 |
| 58 SkFixed normalizeFixedY(SkFixed y) const { |
| 59 SkASSERT(SkIsPow2(fTexture->fDesc.fHeight)); |
| 60 return y >> fTexture->fShiftFixedY; |
| 61 } |
| 62 |
| 63 private: |
| 64 GrTexturePriv(GrTexture* texture) : fTexture(texture) { } |
| 65 |
| 66 // No taking addresses of this type. |
| 67 const GrTexturePriv* operator&() const; |
| 68 GrTexturePriv* operator&(); |
| 69 |
| 70 GrTexture* fTexture; |
| 71 |
| 72 friend class GrTexture; // to construct this type. |
| 73 }; |
| 74 |
| 75 inline GrTexturePriv GrTexture::texturePriv() { return GrTexturePriv(this); } |
| 76 |
| 77 inline const GrTexturePriv GrTexture::texturePriv () const { |
| 78 return GrTexturePriv(const_cast<GrTexture*>(this)); |
| 79 } |
| 80 |
| 81 #endif |
OLD | NEW |