blob: 085e78d787272f825c3d550c95a746ee2f58d787 [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
Brian Salomon201cdbb2019-08-14 17:00:30 -040011#include "src/gpu/GrSamplerState.h"
Greg Daniel456f9b52020-03-05 19:14:18 +000012#include "src/gpu/GrTexture.h"
bsalomonafbf2d62014-09-30 12:18:44 -070013
14/** Class that adds methods to GrTexture that are only intended for use internal to Skia.
15 This class is purely a privileged window into GrTexture. It should never have additional data
16 members or virtual methods.
17 Non-static methods that are not trivial inlines should be spring-boarded (e.g. declared and
18 implemented privately in GrTexture with a inline public method here). */
19class GrTexturePriv {
20public:
Greg Daniel0fc4d2d2017-10-12 11:23:36 -040021 void markMipMapsDirty() {
22 fTexture->markMipMapsDirty();
23 }
24
25 void markMipMapsClean() {
26 fTexture->markMipMapsClean();
brianosman33f6b3f2016-06-02 05:49:21 -070027 }
bsalomonafbf2d62014-09-30 12:18:44 -070028
Chris Dalton95d8ceb2019-07-30 11:17:59 -060029 GrMipMapsStatus mipMapsStatus() const { return fTexture->fMipMapsStatus; }
30
bsalomonafbf2d62014-09-30 12:18:44 -070031 bool mipMapsAreDirty() const {
Chris Dalton95d8ceb2019-07-30 11:17:59 -060032 return GrMipMapsStatus::kValid != this->mipMapsStatus();
bsalomonafbf2d62014-09-30 12:18:44 -070033 }
34
Greg Daniele252f082017-10-23 16:05:23 -040035 GrMipMapped mipMapped() const {
Chris Dalton95d8ceb2019-07-30 11:17:59 -060036 if (GrMipMapsStatus::kNotAllocated != this->mipMapsStatus()) {
Greg Daniele252f082017-10-23 16:05:23 -040037 return GrMipMapped::kYes;
38 }
39 return GrMipMapped::kNo;
Greg Daniel834f1202017-10-09 15:06:20 -040040 }
41
cblume55f2d2d2016-02-26 13:20:48 -080042 int maxMipMapLevel() const {
43 return fTexture->fMaxMipMapLevel;
44 }
45
Brian Salomon60dd8c72018-07-30 10:24:13 -040046 GrTextureType textureType() const { return fTexture->fTextureType; }
Brian Salomon7226c232018-07-30 13:13:17 -040047 bool hasRestrictedSampling() const {
48 return GrTextureTypeHasRestrictedSampling(this->textureType());
49 }
Brian Salomon739c5bf2016-11-07 09:53:44 -050050
Greg Danield51fa2f2020-01-22 16:53:38 -050051 static void ComputeScratchKey(const GrCaps& caps,
52 const GrBackendFormat& format,
Brian Salomon9f2b86c2019-10-22 10:37:46 -040053 SkISize dimensions,
Brian Salomon14cb4132019-09-16 13:14:47 -040054 GrRenderable,
55 int sampleCnt,
56 GrMipMapped,
57 GrProtected,
58 GrScratchKey* key);
Brian Salomoncfe910d2017-07-06 16:40:18 -040059
60private:
bsalomonafbf2d62014-09-30 12:18:44 -070061 GrTexturePriv(GrTexture* texture) : fTexture(texture) { }
62 GrTexturePriv(const GrTexturePriv& that) : fTexture(that.fTexture) { }
63 GrTexturePriv& operator=(const GrTexturePriv&); // unimpl
64
65 // No taking addresses of this type.
66 const GrTexturePriv* operator&() const;
67 GrTexturePriv* operator&();
68
69 GrTexture* fTexture;
cblume61214052016-01-26 09:10:48 -080070
bsalomonafbf2d62014-09-30 12:18:44 -070071 friend class GrTexture; // to construct/copy this type.
72};
73
74inline GrTexturePriv GrTexture::texturePriv() { return GrTexturePriv(this); }
75
76inline const GrTexturePriv GrTexture::texturePriv () const {
77 return GrTexturePriv(const_cast<GrTexture*>(this));
78}
79
80#endif