blob: fee7ed1f960df51275118278c70a0595ae366c21 [file] [log] [blame]
bsalomonafbf2d62014-09-30 12:18:44 -07001/*
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
13/** Class that adds methods to GrTexture that are only intended for use internal to Skia.
14 This class is purely a privileged window into GrTexture. It should never have additional data
15 members or virtual methods.
16 Non-static methods that are not trivial inlines should be spring-boarded (e.g. declared and
17 implemented privately in GrTexture with a inline public method here). */
18class GrTexturePriv {
19public:
bsalomonf2703d82014-10-28 14:33:06 -070020 void setFlag(GrSurfaceFlags flags) {
bsalomonafbf2d62014-09-30 12:18:44 -070021 fTexture->fDesc.fFlags = fTexture->fDesc.fFlags | flags;
22 }
23
bsalomonf2703d82014-10-28 14:33:06 -070024 void resetFlag(GrSurfaceFlags flags) {
bsalomonafbf2d62014-09-30 12:18:44 -070025 fTexture->fDesc.fFlags = fTexture->fDesc.fFlags & ~flags;
26 }
27
bsalomonf2703d82014-10-28 14:33:06 -070028 bool isSetFlag(GrSurfaceFlags flags) const {
bsalomonafbf2d62014-09-30 12:18:44 -070029 return 0 != (fTexture->fDesc.fFlags & flags);
30 }
31
32 void dirtyMipMaps(bool mipMapsDirty) { fTexture->dirtyMipMaps(mipMapsDirty); }
33
34 bool mipMapsAreDirty() const {
35 return GrTexture::kValid_MipMapsStatus != fTexture->fMipMapsStatus;
36 }
37
38 bool hasMipMaps() const {
39 return GrTexture::kNotAllocated_MipMapsStatus != fTexture->fMipMapsStatus;
40 }
41
cblume55f2d2d2016-02-26 13:20:48 -080042 void setMaxMipMapLevel(int maxMipMapLevel) const {
43 fTexture->fMaxMipMapLevel = maxMipMapLevel;
44 }
45
46 int maxMipMapLevel() const {
47 return fTexture->fMaxMipMapLevel;
48 }
49
bsalomon7775c852014-12-30 12:50:52 -080050 static void ComputeScratchKey(const GrSurfaceDesc&, GrScratchKey*);
bsalomonafbf2d62014-09-30 12:18:44 -070051
bsalomonafbf2d62014-09-30 12:18:44 -070052private:
53 GrTexturePriv(GrTexture* texture) : fTexture(texture) { }
54 GrTexturePriv(const GrTexturePriv& that) : fTexture(that.fTexture) { }
55 GrTexturePriv& operator=(const GrTexturePriv&); // unimpl
56
57 // No taking addresses of this type.
58 const GrTexturePriv* operator&() const;
59 GrTexturePriv* operator&();
60
61 GrTexture* fTexture;
cblume61214052016-01-26 09:10:48 -080062
bsalomonafbf2d62014-09-30 12:18:44 -070063 friend class GrTexture; // to construct/copy this type.
64};
65
66inline GrTexturePriv GrTexture::texturePriv() { return GrTexturePriv(this); }
67
68inline const GrTexturePriv GrTexture::texturePriv () const {
69 return GrTexturePriv(const_cast<GrTexture*>(this));
70}
71
72#endif