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: asTexture()21 GrTexture* asTexture() override { return this; } asTexture()22 const GrTexture* asTexture() const override { return this; } 23 24 /** 25 * Return the native ID or handle to the texture, depending on the 26 * platform. e.g. on OpenGL, return the texture ID. 27 */ 28 virtual GrBackendObject getTextureHandle() const = 0; 29 30 /** 31 * This function indicates that the texture parameters (wrap mode, filtering, ...) have been 32 * changed externally to Skia. 33 */ 34 virtual void textureParamsModified() = 0; 35 36 #ifdef SK_DEBUG validate()37 void validate() const { 38 this->INHERITED::validate(); 39 this->validateDesc(); 40 } 41 #endif 42 43 /** Access methods that are only to be used within Skia code. */ 44 inline GrTexturePriv texturePriv(); 45 inline const GrTexturePriv texturePriv() const; 46 47 protected: 48 GrTexture(GrGpu*, LifeCycle, const GrSurfaceDesc&); 49 50 void validateDesc() const; 51 52 private: 53 size_t onGpuMemorySize() const override; 54 void dirtyMipMaps(bool mipMapsDirty); 55 56 enum MipMapsStatus { 57 kNotAllocated_MipMapsStatus, 58 kAllocated_MipMapsStatus, 59 kValid_MipMapsStatus 60 }; 61 62 MipMapsStatus fMipMapsStatus; 63 64 friend class GrTexturePriv; 65 66 typedef GrSurface INHERITED; 67 }; 68 69 #endif 70