Skia
2DGraphicsLibrary
 All Classes Namespaces 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 "GrSamplerParams.h"
14 #include "SkPoint.h"
15 #include "SkRefCnt.h"
16 
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 
28  virtual GrBackendObject getTextureHandle() const = 0;
29 
34  virtual void textureParamsModified() = 0;
35 
36 #ifdef SK_DEBUG
37  void validate() const {
38  this->INHERITED::validate();
39  }
40 #endif
41 
42  // These match the definitions in SkImage, for whence they came
43  typedef void* ReleaseCtx;
44  typedef void (*ReleaseProc)(ReleaseCtx);
45 
46  virtual void setRelease(ReleaseProc proc, ReleaseCtx ctx) = 0;
47 
49  inline GrTexturePriv texturePriv();
50  inline const GrTexturePriv texturePriv() const;
51 
52 protected:
53  GrTexture(GrGpu*, const GrSurfaceDesc&, GrSLType samplerType,
54  GrSamplerParams::FilterMode highestFilterMode, bool wasMipMapDataProvided);
55 
56 private:
57  void computeScratchKey(GrScratchKey*) const override;
58  size_t onGpuMemorySize() const override;
59  void dirtyMipMaps(bool mipMapsDirty);
60 
61  enum MipMapsStatus {
62  kNotAllocated_MipMapsStatus,
63  kAllocated_MipMapsStatus,
64  kValid_MipMapsStatus
65  };
66 
67  GrSLType fSamplerType;
68  GrSamplerParams::FilterMode fHighestFilterMode;
69  MipMapsStatus fMipMapsStatus;
70  int fMaxMipMapLevel;
71  SkDestinationSurfaceColorMode fMipColorMode;
72  friend class GrTexturePriv;
73 
74  typedef GrSurface INHERITED;
75 };
76 
77 #endif
Describes a surface to be created.
Definition: GrTypes.h:589
void computeScratchKey(GrScratchKey *) const override
Called by the registerWithCache if the resource is available to be used as scratch.
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:168
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