blob: 1cdd2dc9f5a37e7294500b8deb8a86f2cbf93bfb [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 Salomon739c5bf2016-11-07 09:53:44 -050043 GrSLType samplerType() const { return fTexture->fSamplerType; }
44
Brian Salomon0bbecb22016-11-17 11:38:22 -050045 /** The filter used is clamped to this value in GrProcessor::TextureSampler. */
Brian Salomon2bbdcc42017-09-07 12:36:34 -040046 GrSamplerState::Filter highestFilterMode() const { return fTexture->fHighestFilterMode; }
Brian Salomon739c5bf2016-11-07 09:53:44 -050047
Greg Daniel21918232017-09-08 14:46:23 -040048 static void ComputeScratchKey(const GrSurfaceDesc&, GrScratchKey*);
Brian Salomond34edf32017-05-19 15:45:48 -040049 static void ComputeScratchKey(GrPixelConfig config, int width, int height,
Robert Phillipsb0e93a22017-08-29 08:26:54 -040050 bool isRenderTarget, int sampleCnt,
Greg Daniele252f082017-10-23 16:05:23 -040051 GrMipMapped, GrScratchKey* key);
Brian Salomond34edf32017-05-19 15:45:48 -040052
Brian Salomoncfe910d2017-07-06 16:40:18 -040053
54private:
bsalomonafbf2d62014-09-30 12:18:44 -070055 GrTexturePriv(GrTexture* texture) : fTexture(texture) { }
56 GrTexturePriv(const GrTexturePriv& that) : fTexture(that.fTexture) { }
57 GrTexturePriv& operator=(const GrTexturePriv&); // unimpl
58
59 // No taking addresses of this type.
60 const GrTexturePriv* operator&() const;
61 GrTexturePriv* operator&();
62
63 GrTexture* fTexture;
cblume61214052016-01-26 09:10:48 -080064
bsalomonafbf2d62014-09-30 12:18:44 -070065 friend class GrTexture; // to construct/copy this type.
66};
67
68inline GrTexturePriv GrTexture::texturePriv() { return GrTexturePriv(this); }
69
70inline const GrTexturePriv GrTexture::texturePriv () const {
71 return GrTexturePriv(const_cast<GrTexture*>(this));
72}
73
74#endif