• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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). */
18 class GrTexturePriv {
19 public:
dirtyMipMaps(bool mipMapsDirty)20     void dirtyMipMaps(bool mipMapsDirty) {
21         fTexture->dirtyMipMaps(mipMapsDirty);
22     }
23 
mipMapsAreDirty()24     bool mipMapsAreDirty() const {
25         return GrTexture::kValid_MipMapsStatus != fTexture->fMipMapsStatus;
26     }
27 
hasMipMaps()28     bool hasMipMaps() const {
29         return GrTexture::kNotAllocated_MipMapsStatus != fTexture->fMipMapsStatus;
30     }
31 
setMaxMipMapLevel(int maxMipMapLevel)32     void setMaxMipMapLevel(int maxMipMapLevel) const {
33         fTexture->fMaxMipMapLevel = maxMipMapLevel;
34     }
35 
maxMipMapLevel()36     int maxMipMapLevel() const {
37         return fTexture->fMaxMipMapLevel;
38     }
39 
imageStorageType()40     GrSLType imageStorageType() const {
41         if (GrPixelConfigIsSint(fTexture->config())) {
42             return kIImageStorage2D_GrSLType;
43         } else {
44             return kImageStorage2D_GrSLType;
45         }
46     }
47 
samplerType()48     GrSLType samplerType() const { return fTexture->fSamplerType; }
49 
50     /** The filter used is clamped to this value in GrProcessor::TextureSampler. */
highestFilterMode()51     GrSamplerParams::FilterMode highestFilterMode() const { return fTexture->fHighestFilterMode; }
52 
setMipColorMode(SkDestinationSurfaceColorMode colorMode)53     void setMipColorMode(SkDestinationSurfaceColorMode colorMode) const {
54         fTexture->fMipColorMode = colorMode;
55     }
mipColorMode()56     SkDestinationSurfaceColorMode mipColorMode() const { return fTexture->fMipColorMode; }
57 
58     static void ComputeScratchKey(const GrSurfaceDesc&, GrScratchKey*);
59     static void ComputeScratchKey(GrPixelConfig config, int width, int height,
60                                   GrSurfaceOrigin origin, bool isRenderTarget, int sampleCnt,
61                                   bool isMipMapped, GrScratchKey* key);
62 
63 
64 private:
GrTexturePriv(GrTexture * texture)65     GrTexturePriv(GrTexture* texture) : fTexture(texture) { }
GrTexturePriv(const GrTexturePriv & that)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;
74 
75     friend class GrTexture; // to construct/copy this type.
76 };
77 
texturePriv()78 inline GrTexturePriv GrTexture::texturePriv() { return GrTexturePriv(this); }
79 
texturePriv()80 inline const GrTexturePriv GrTexture::texturePriv () const {
81     return GrTexturePriv(const_cast<GrTexture*>(this));
82 }
83 
84 #endif
85