Chromium Code Reviews| Index: src/gpu/GrTexturePriv.h |
| diff --git a/src/gpu/GrTexturePriv.h b/src/gpu/GrTexturePriv.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..706c670b4843c99da28c94433654828d7d08516b |
| --- /dev/null |
| +++ b/src/gpu/GrTexturePriv.h |
| @@ -0,0 +1,81 @@ |
| +/* |
| + * Copyright 2014 Google Inc. |
| + * |
| + * Use of this source code is governed by a BSD-style license that can be |
| + * found in the LICENSE file. |
| + */ |
| + |
| +#ifndef GrTexturePriv_DEFINED |
| +#define GrTexturePriv_DEFINED |
| + |
| +#include "GrTexture.h" |
| +#include "SkRefCnt.h" |
| + |
| +/** Class that adds methods to GrTexture that are only intended for use internal to Skia. |
|
robertphillips
2014/09/29 19:22:00
privileged
bsalomon
2014/09/29 19:46:29
Done.
|
| + This class is purely a priveledged window into GrTexture. It should never have additional data |
| + members or virtual methods. |
| + Non-static methods that are not trivial inlines should be spring-boarded (e.g. declared and |
| + implemented privately in GrTexture with a inline public method here). */ |
| +class GrTexturePriv : SkNoncopyable { |
| +public: |
| + void setFlag(GrTextureFlags flags) { |
| + fTexture->fDesc.fFlags = fTexture->fDesc.fFlags | flags; |
| + } |
| + |
| + void resetFlag(GrTextureFlags flags) { |
| + fTexture->fDesc.fFlags = fTexture->fDesc.fFlags & ~flags; |
| + } |
| + |
| + bool isSetFlag(GrTextureFlags flags) const { |
| + return 0 != (fTexture->fDesc.fFlags & flags); |
| + } |
| + |
| + void dirtyMipMaps(bool mipMapsDirty); |
| + |
| + bool mipMapsAreDirty() const { |
| + return GrTexture::kValid_MipMapsStatus != fTexture->fMipMapsStatus; |
| + } |
| + |
| + bool hasMipMaps() const { |
| + return GrTexture::kNotAllocated_MipMapsStatus != fTexture->fMipMapsStatus; |
| + } |
| + |
| + static GrResourceKey ComputeKey(const GrGpu* gpu, |
| + const GrTextureParams* params, |
| + const GrTextureDesc& desc, |
| + const GrCacheID& cacheID); |
| + static GrResourceKey ComputeScratchKey(const GrTextureDesc& desc); |
| + static bool NeedsResizing(const GrResourceKey& key); |
| + static bool NeedsBilerp(const GrResourceKey& key); |
| + |
| + |
| + // TODO: Move this logic and the shift values out of here and to the callers. |
| + SkFixed normalizeFixedX(SkFixed x) const { |
| + SkASSERT(SkIsPow2(fTexture->fDesc.fWidth)); |
| + return x >> fTexture->fShiftFixedX; |
| + } |
| + |
| + SkFixed normalizeFixedY(SkFixed y) const { |
| + SkASSERT(SkIsPow2(fTexture->fDesc.fHeight)); |
| + return y >> fTexture->fShiftFixedY; |
| + } |
| + |
| +private: |
| + GrTexturePriv(GrTexture* texture) : fTexture(texture) { } |
| + |
| + // No taking addresses of this type. |
| + const GrTexturePriv* operator&() const; |
| + GrTexturePriv* operator&(); |
| + |
| + GrTexture* fTexture; |
| + |
| + friend class GrTexture; // to construct this type. |
| +}; |
| + |
| +inline GrTexturePriv GrTexture::texturePriv() { return GrTexturePriv(this); } |
| + |
| +inline const GrTexturePriv GrTexture::texturePriv () const { |
| + return GrTexturePriv(const_cast<GrTexture*>(this)); |
| +} |
| + |
| +#endif |