blob: ee767bf4c531888e02e103c21d22fc50ed1f2a58 [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 int maxMipMapLevel() const {
40 return fTexture->fMaxMipMapLevel;
41 }
42
Brian Salomon60dd8c72018-07-30 10:24:13 -040043 GrTextureType textureType() const { return fTexture->fTextureType; }
Brian Salomon7226c232018-07-30 13:13:17 -040044 bool hasRestrictedSampling() const {
45 return GrTextureTypeHasRestrictedSampling(this->textureType());
46 }
Brian Salomone632dfc2018-08-01 13:01:16 -040047 /** Filtering is clamped to this value. */
48 GrSamplerState::Filter highestFilterMode() const {
49 return this->hasRestrictedSampling() ? GrSamplerState::Filter::kBilerp
50 : GrSamplerState::Filter::kMipMap;
51 }
Brian Salomon739c5bf2016-11-07 09:53:44 -050052
Greg Daniel21918232017-09-08 14:46:23 -040053 static void ComputeScratchKey(const GrSurfaceDesc&, GrScratchKey*);
Brian Salomond34edf32017-05-19 15:45:48 -040054 static void ComputeScratchKey(GrPixelConfig config, int width, int height,
Robert Phillipsb0e93a22017-08-29 08:26:54 -040055 bool isRenderTarget, int sampleCnt,
Greg Daniele252f082017-10-23 16:05:23 -040056 GrMipMapped, GrScratchKey* key);
Brian Salomond34edf32017-05-19 15:45:48 -040057
Brian Salomoncfe910d2017-07-06 16:40:18 -040058
59private:
bsalomonafbf2d62014-09-30 12:18:44 -070060 GrTexturePriv(GrTexture* texture) : fTexture(texture) { }
61 GrTexturePriv(const GrTexturePriv& that) : fTexture(that.fTexture) { }
62 GrTexturePriv& operator=(const GrTexturePriv&); // unimpl
63
64 // No taking addresses of this type.
65 const GrTexturePriv* operator&() const;
66 GrTexturePriv* operator&();
67
68 GrTexture* fTexture;
cblume61214052016-01-26 09:10:48 -080069
bsalomonafbf2d62014-09-30 12:18:44 -070070 friend class GrTexture; // to construct/copy this type.
71};
72
73inline GrTexturePriv GrTexture::texturePriv() { return GrTexturePriv(this); }
74
75inline const GrTexturePriv GrTexture::texturePriv () const {
76 return GrTexturePriv(const_cast<GrTexture*>(this));
77}
78
79#endif