blob: 80ac75fdb80240a1d0d1cbf142c5505cf62b9ff0 [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
Greg Daniele3204862018-04-16 11:24:10 -040047 void setDoesNotSupportMipMaps() {
48 fTexture->setDoesNotSupportMipMaps();
49 }
50
Brian Salomon739c5bf2016-11-07 09:53:44 -050051 GrSLType samplerType() const { return fTexture->fSamplerType; }
52
Brian Salomon0bbecb22016-11-17 11:38:22 -050053 /** The filter used is clamped to this value in GrProcessor::TextureSampler. */
Brian Salomon2bbdcc42017-09-07 12:36:34 -040054 GrSamplerState::Filter highestFilterMode() const { return fTexture->fHighestFilterMode; }
Brian Salomon739c5bf2016-11-07 09:53:44 -050055
Brian Osman7b8400d2016-11-08 17:08:54 -050056 void setMipColorMode(SkDestinationSurfaceColorMode colorMode) const {
57 fTexture->fMipColorMode = colorMode;
brianosman33f6b3f2016-06-02 05:49:21 -070058 }
Brian Osman7b8400d2016-11-08 17:08:54 -050059 SkDestinationSurfaceColorMode mipColorMode() const { return fTexture->fMipColorMode; }
brianosman33f6b3f2016-06-02 05:49:21 -070060
Greg Daniel21918232017-09-08 14:46:23 -040061 static void ComputeScratchKey(const GrSurfaceDesc&, GrScratchKey*);
Brian Salomond34edf32017-05-19 15:45:48 -040062 static void ComputeScratchKey(GrPixelConfig config, int width, int height,
Robert Phillipsb0e93a22017-08-29 08:26:54 -040063 bool isRenderTarget, int sampleCnt,
Greg Daniele252f082017-10-23 16:05:23 -040064 GrMipMapped, GrScratchKey* key);
Brian Salomond34edf32017-05-19 15:45:48 -040065
Brian Salomoncfe910d2017-07-06 16:40:18 -040066
67private:
bsalomonafbf2d62014-09-30 12:18:44 -070068 GrTexturePriv(GrTexture* texture) : fTexture(texture) { }
69 GrTexturePriv(const GrTexturePriv& that) : fTexture(that.fTexture) { }
70 GrTexturePriv& operator=(const GrTexturePriv&); // unimpl
71
72 // No taking addresses of this type.
73 const GrTexturePriv* operator&() const;
74 GrTexturePriv* operator&();
75
76 GrTexture* fTexture;
cblume61214052016-01-26 09:10:48 -080077
bsalomonafbf2d62014-09-30 12:18:44 -070078 friend class GrTexture; // to construct/copy this type.
79};
80
81inline GrTexturePriv GrTexture::texturePriv() { return GrTexturePriv(this); }
82
83inline const GrTexturePriv GrTexture::texturePriv () const {
84 return GrTexturePriv(const_cast<GrTexture*>(this));
85}
86
87#endif