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 17class GrTexturePriv; 18 19class GrTexture : virtual public GrSurface { 20public: 21 GrTexture* asTexture() override { return this; } 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 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 48 /** Access methods that are only to be used within Skia code. */ 49 inline GrTexturePriv texturePriv(); 50 inline const GrTexturePriv texturePriv() const; 51 52protected: 53 GrTexture(GrGpu*, const GrSurfaceDesc&, GrSLType samplerType, 54 GrSamplerParams::FilterMode highestFilterMode, bool wasMipMapDataProvided); 55 56private: 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 78