blob: e8721bc62c88badc10ab94c88a3c3ce3f5139ff4 [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
brianosmanfe199872016-06-13 07:59:48 -070032 void dirtyMipMaps(bool mipMapsDirty) {
33 fTexture->dirtyMipMaps(mipMapsDirty);
brianosman33f6b3f2016-06-02 05:49:21 -070034 }
bsalomonafbf2d62014-09-30 12:18:44 -070035
36 bool mipMapsAreDirty() const {
37 return GrTexture::kValid_MipMapsStatus != fTexture->fMipMapsStatus;
38 }
39
40 bool hasMipMaps() const {
41 return GrTexture::kNotAllocated_MipMapsStatus != fTexture->fMipMapsStatus;
42 }
43
cblume55f2d2d2016-02-26 13:20:48 -080044 void setMaxMipMapLevel(int maxMipMapLevel) const {
45 fTexture->fMaxMipMapLevel = maxMipMapLevel;
46 }
47
48 int maxMipMapLevel() const {
49 return fTexture->fMaxMipMapLevel;
50 }
51
Brian Salomon739c5bf2016-11-07 09:53:44 -050052 GrSLType samplerType() const { return fTexture->fSamplerType; }
53
54 /** The filter used is clamped to this value in GrTextureAccess. */
55 GrTextureParams::FilterMode highestFilterMode() const { return fTexture->fHighestFilterMode; }
56
Brian Osman7b8400d2016-11-08 17:08:54 -050057 void setMipColorMode(SkDestinationSurfaceColorMode colorMode) const {
58 fTexture->fMipColorMode = colorMode;
brianosman33f6b3f2016-06-02 05:49:21 -070059 }
Brian Osman7b8400d2016-11-08 17:08:54 -050060 SkDestinationSurfaceColorMode mipColorMode() const { return fTexture->fMipColorMode; }
brianosman33f6b3f2016-06-02 05:49:21 -070061
bsalomon7775c852014-12-30 12:50:52 -080062 static void ComputeScratchKey(const GrSurfaceDesc&, GrScratchKey*);
bsalomonafbf2d62014-09-30 12:18:44 -070063
bsalomonafbf2d62014-09-30 12:18:44 -070064private:
65 GrTexturePriv(GrTexture* texture) : fTexture(texture) { }
66 GrTexturePriv(const GrTexturePriv& that) : fTexture(that.fTexture) { }
67 GrTexturePriv& operator=(const GrTexturePriv&); // unimpl
68
69 // No taking addresses of this type.
70 const GrTexturePriv* operator&() const;
71 GrTexturePriv* operator&();
72
73 GrTexture* fTexture;
cblume61214052016-01-26 09:10:48 -080074
bsalomonafbf2d62014-09-30 12:18:44 -070075 friend class GrTexture; // to construct/copy this type.
76};
77
78inline GrTexturePriv GrTexture::texturePriv() { return GrTexturePriv(this); }
79
80inline const GrTexturePriv GrTexture::texturePriv () const {
81 return GrTexturePriv(const_cast<GrTexture*>(this));
82}
83
84#endif