Skia
2DGraphicsLibrary
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GrTexture.h
1 
2 /*
3  * Copyright 2011 Google Inc.
4  *
5  * Use of this source code is governed by a BSD-style license that can be
6  * found in the LICENSE file.
7  */
8 
9 #ifndef GrTexture_DEFINED
10 #define GrTexture_DEFINED
11 
12 #include "GrSurface.h"
13 #include "SkPoint.h"
14 #include "SkRefCnt.h"
15 
16 class GrTextureParams;
17 class GrTexturePriv;
18 
19 class GrTexture : virtual public GrSurface {
20 public:
21  GrTexture* asTexture() override { return this; }
22  const GrTexture* asTexture() const override { return this; }
23  GrSLType samplerType() const { return fSamplerType; }
24 
29  virtual GrBackendObject getTextureHandle() const = 0;
30 
35  virtual void textureParamsModified() = 0;
36 
37 #ifdef SK_DEBUG
38  void validate() const {
39  this->INHERITED::validate();
40  this->validateDesc();
41  }
42 #endif
43 
45  inline GrTexturePriv texturePriv();
46  inline const GrTexturePriv texturePriv() const;
47 
48 protected:
49  GrTexture(GrGpu*, const GrSurfaceDesc&, GrSLType, bool wasMipMapDataProvided);
50 
51  void validateDesc() const;
52 
53 private:
54  void computeScratchKey(GrScratchKey*) const override;
55  size_t onGpuMemorySize() const override;
56  void dirtyMipMaps(bool mipMapsDirty);
57 
58  enum MipMapsStatus {
59  kNotAllocated_MipMapsStatus,
60  kAllocated_MipMapsStatus,
61  kValid_MipMapsStatus
62  };
63 
64  GrSLType fSamplerType;
65  MipMapsStatus fMipMapsStatus;
66  int fMaxMipMapLevel;
67  SkSourceGammaTreatment fGammaTreatment;
68 
69  friend class GrTexturePriv;
70 
71  typedef GrSurface INHERITED;
72 };
73 
74 #endif
Describes a surface to be created.
Definition: GrTypes.h:467
void computeScratchKey(GrScratchKey *) const override
Called by the registerWithCache if the resource is available to be used as scratch.
Represents the filtering and tile modes used to access a texture.
Definition: GrTextureParams.h:17
GrTexture * asTexture() override
Definition: GrTexture.h:21
Definition: GrSurface.h:21
virtual void textureParamsModified()=0
This function indicates that the texture parameters (wrap mode, filtering, ...) have been changed ext...
A key used for scratch resources.
Definition: GrResourceKey.h:166
GrTexturePriv texturePriv()
Access methods that are only to be used within Skia code.
virtual GrBackendObject getTextureHandle() const =0
Return the native ID or handle to the texture, depending on the platform.
Definition: GrTexture.h:19