blob: ad69d3133cbf72797f9bc3d839d236829270d83f [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:
Greg Daniel0fc4d2d2017-10-12 11:23:36 -040020 void markMipMapsDirty() {
21 fTexture->markMipMapsDirty();
22 }
23
24 void markMipMapsClean() {
25 fTexture->markMipMapsClean();
brianosman33f6b3f2016-06-02 05:49:21 -070026 }
bsalomonafbf2d62014-09-30 12:18:44 -070027
28 bool mipMapsAreDirty() const {
Greg Daniel0fc4d2d2017-10-12 11:23:36 -040029 return GrMipMapsStatus::kValid != fTexture->fMipMapsStatus;
bsalomonafbf2d62014-09-30 12:18:44 -070030 }
31
Greg Daniele252f082017-10-23 16:05:23 -040032 GrMipMapped mipMapped() const {
33 if (GrMipMapsStatus::kNotAllocated != fTexture->fMipMapsStatus) {
34 return GrMipMapped::kYes;
35 }
36 return GrMipMapped::kNo;
Greg Daniel834f1202017-10-09 15:06:20 -040037 }
38
cblume55f2d2d2016-02-26 13:20:48 -080039 void setMaxMipMapLevel(int maxMipMapLevel) const {
40 fTexture->fMaxMipMapLevel = maxMipMapLevel;
41 }
42
43 int maxMipMapLevel() const {
44 return fTexture->fMaxMipMapLevel;
45 }
46
Brian Salomon739c5bf2016-11-07 09:53:44 -050047 GrSLType samplerType() const { return fTexture->fSamplerType; }
48
Brian Salomon0bbecb22016-11-17 11:38:22 -050049 /** The filter used is clamped to this value in GrProcessor::TextureSampler. */
Brian Salomon2bbdcc42017-09-07 12:36:34 -040050 GrSamplerState::Filter highestFilterMode() const { return fTexture->fHighestFilterMode; }
Brian Salomon739c5bf2016-11-07 09:53:44 -050051
Brian Osman7b8400d2016-11-08 17:08:54 -050052 void setMipColorMode(SkDestinationSurfaceColorMode colorMode) const {
53 fTexture->fMipColorMode = colorMode;
brianosman33f6b3f2016-06-02 05:49:21 -070054 }
Brian Osman7b8400d2016-11-08 17:08:54 -050055 SkDestinationSurfaceColorMode mipColorMode() const { return fTexture->fMipColorMode; }
brianosman33f6b3f2016-06-02 05:49:21 -070056
Greg Daniel21918232017-09-08 14:46:23 -040057 static void ComputeScratchKey(const GrSurfaceDesc&, GrScratchKey*);
Brian Salomond34edf32017-05-19 15:45:48 -040058 static void ComputeScratchKey(GrPixelConfig config, int width, int height,
Robert Phillipsb0e93a22017-08-29 08:26:54 -040059 bool isRenderTarget, int sampleCnt,
Greg Daniele252f082017-10-23 16:05:23 -040060 GrMipMapped, GrScratchKey* key);
Brian Salomond34edf32017-05-19 15:45:48 -040061
Brian Salomoncfe910d2017-07-06 16:40:18 -040062
63private:
bsalomonafbf2d62014-09-30 12:18:44 -070064 GrTexturePriv(GrTexture* texture) : fTexture(texture) { }
65 GrTexturePriv(const GrTexturePriv& that) : fTexture(that.fTexture) { }
66 GrTexturePriv& operator=(const GrTexturePriv&); // unimpl
67
68 // No taking addresses of this type.
69 const GrTexturePriv* operator&() const;
70 GrTexturePriv* operator&();
71
72 GrTexture* fTexture;
cblume61214052016-01-26 09:10:48 -080073
bsalomonafbf2d62014-09-30 12:18:44 -070074 friend class GrTexture; // to construct/copy this type.
75};
76
77inline GrTexturePriv GrTexture::texturePriv() { return GrTexturePriv(this); }
78
79inline const GrTexturePriv GrTexture::texturePriv () const {
80 return GrTexturePriv(const_cast<GrTexture*>(this));
81}
82
83#endif