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 "src/gpu/GrSamplerState.h"
12#include "src/gpu/GrTexture.h"
13
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:
21 void markMipMapsDirty() {
22 fTexture->markMipMapsDirty();
23 }
24
25 void markMipMapsClean() {
26 fTexture->markMipMapsClean();
27 }
28
29 GrMipMapsStatus mipMapsStatus() const { return fTexture->fMipMapsStatus; }
30
31 bool mipMapsAreDirty() const {
32 return GrMipMapsStatus::kValid != this->mipMapsStatus();
33 }
34
35 GrMipMapped mipMapped() const {
36 if (GrMipMapsStatus::kNotAllocated != this->mipMapsStatus()) {
37 return GrMipMapped::kYes;
38 }
39 return GrMipMapped::kNo;
40 }
41
42 int maxMipMapLevel() const {
43 return fTexture->fMaxMipMapLevel;
44 }
45
46 GrTextureType textureType() const { return fTexture->fTextureType; }
47 bool hasRestrictedSampling() const {
48 return GrTextureTypeHasRestrictedSampling(this->textureType());
49 }
50
51 static void ComputeScratchKey(const GrCaps& caps,
52 const GrBackendFormat& format,
53 SkISize dimensions,
54 GrRenderable,
55 int sampleCnt,
56 GrMipMapped,
57 GrProtected,
58 GrScratchKey* key);
59
60private:
61 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;
70
71 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
81