blob: 67631fc2c4acaab7875e666c257d2e47a75e5bb9 [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:
brianosmanfe199872016-06-13 07:59:48 -070020 void dirtyMipMaps(bool mipMapsDirty) {
21 fTexture->dirtyMipMaps(mipMapsDirty);
brianosman33f6b3f2016-06-02 05:49:21 -070022 }
bsalomonafbf2d62014-09-30 12:18:44 -070023
24 bool mipMapsAreDirty() const {
25 return GrTexture::kValid_MipMapsStatus != fTexture->fMipMapsStatus;
26 }
27
28 bool hasMipMaps() const {
29 return GrTexture::kNotAllocated_MipMapsStatus != fTexture->fMipMapsStatus;
30 }
31
cblume55f2d2d2016-02-26 13:20:48 -080032 void setMaxMipMapLevel(int maxMipMapLevel) const {
33 fTexture->fMaxMipMapLevel = maxMipMapLevel;
34 }
35
36 int maxMipMapLevel() const {
37 return fTexture->fMaxMipMapLevel;
38 }
39
Brian Salomonf9f45122016-11-29 11:59:17 -050040 GrSLType imageStorageType() const {
41 if (GrPixelConfigIsSint(fTexture->config())) {
42 return kIImageStorage2D_GrSLType;
43 } else {
44 return kImageStorage2D_GrSLType;
45 }
46 }
47
Brian Salomon739c5bf2016-11-07 09:53:44 -050048 GrSLType samplerType() const { return fTexture->fSamplerType; }
49
Brian Salomon0bbecb22016-11-17 11:38:22 -050050 /** The filter used is clamped to this value in GrProcessor::TextureSampler. */
Brian Salomon514baff2016-11-17 15:17:07 -050051 GrSamplerParams::FilterMode highestFilterMode() const { return fTexture->fHighestFilterMode; }
Brian Salomon739c5bf2016-11-07 09:53:44 -050052
Brian Osman7b8400d2016-11-08 17:08:54 -050053 void setMipColorMode(SkDestinationSurfaceColorMode colorMode) const {
54 fTexture->fMipColorMode = colorMode;
brianosman33f6b3f2016-06-02 05:49:21 -070055 }
Brian Osman7b8400d2016-11-08 17:08:54 -050056 SkDestinationSurfaceColorMode mipColorMode() const { return fTexture->fMipColorMode; }
brianosman33f6b3f2016-06-02 05:49:21 -070057
bsalomon7775c852014-12-30 12:50:52 -080058 static void ComputeScratchKey(const GrSurfaceDesc&, GrScratchKey*);
bsalomonafbf2d62014-09-30 12:18:44 -070059
bsalomonafbf2d62014-09-30 12:18:44 -070060private:
Brian Salomond34edf32017-05-19 15:45:48 -040061 static void ComputeScratchKey(GrPixelConfig config, int width, int height,
62 GrSurfaceOrigin origin, bool isRenderTarget, int sampleCnt,
63 bool isMipMapped, GrScratchKey* key);
64
bsalomonafbf2d62014-09-30 12:18:44 -070065 GrTexturePriv(GrTexture* texture) : fTexture(texture) { }
66 GrTexturePriv(const GrTexturePriv& that) : fTexture(that.fTexture) { }
67 GrTexturePriv& operator=(const GrTexturePriv&); // unimpl
68
69 // No taking addresses of this type.
70 const GrTexturePriv* operator&() const;
71 GrTexturePriv* operator&();
72
73 GrTexture* fTexture;
cblume61214052016-01-26 09:10:48 -080074
bsalomonafbf2d62014-09-30 12:18:44 -070075 friend class GrTexture; // to construct/copy this type.
76};
77
78inline GrTexturePriv GrTexture::texturePriv() { return GrTexturePriv(this); }
79
80inline const GrTexturePriv GrTexture::texturePriv () const {
81 return GrTexturePriv(const_cast<GrTexture*>(this));
82}
83
84#endif