2010-12-22 21:39:39 +00:00
|
|
|
|
2011-07-28 14:26:00 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2011 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
2010-12-22 21:39:39 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GrTexture_DEFINED
|
|
|
|
#define GrTexture_DEFINED
|
|
|
|
|
2012-06-21 21:09:06 +00:00
|
|
|
#include "GrSurface.h"
|
2014-07-25 14:32:33 +00:00
|
|
|
#include "SkPoint.h"
|
|
|
|
#include "SkRefCnt.h"
|
2010-12-22 21:39:39 +00:00
|
|
|
|
2012-07-25 21:27:09 +00:00
|
|
|
class GrTextureParams;
|
2014-09-30 19:18:44 +00:00
|
|
|
class GrTexturePriv;
|
2010-12-22 21:39:39 +00:00
|
|
|
|
2014-11-03 16:47:23 +00:00
|
|
|
class GrTexture : virtual public GrSurface {
|
2010-12-22 21:39:39 +00:00
|
|
|
public:
|
2015-03-26 01:17:31 +00:00
|
|
|
GrTexture* asTexture() override { return this; }
|
|
|
|
const GrTexture* asTexture() const override { return this; }
|
2016-03-11 18:07:37 +00:00
|
|
|
GrSLType samplerType() const { return fSamplerType; }
|
2011-04-05 17:08:27 +00:00
|
|
|
|
2010-12-22 21:39:39 +00:00
|
|
|
/**
|
|
|
|
* Return the native ID or handle to the texture, depending on the
|
2012-10-25 18:56:10 +00:00
|
|
|
* platform. e.g. on OpenGL, return the texture ID.
|
2010-12-22 21:39:39 +00:00
|
|
|
*/
|
2012-10-25 18:56:10 +00:00
|
|
|
virtual GrBackendObject getTextureHandle() const = 0;
|
2010-12-22 21:39:39 +00:00
|
|
|
|
2014-05-09 18:02:51 +00:00
|
|
|
/**
|
2014-05-09 20:46:48 +00:00
|
|
|
* This function indicates that the texture parameters (wrap mode, filtering, ...) have been
|
|
|
|
* changed externally to Skia.
|
2014-05-09 18:02:51 +00:00
|
|
|
*/
|
2014-05-09 20:46:48 +00:00
|
|
|
virtual void textureParamsModified() = 0;
|
|
|
|
|
2013-08-28 14:17:03 +00:00
|
|
|
#ifdef SK_DEBUG
|
2010-12-22 21:39:39 +00:00
|
|
|
void validate() const {
|
|
|
|
this->INHERITED::validate();
|
2012-06-04 12:48:45 +00:00
|
|
|
this->validateDesc();
|
2010-12-22 21:39:39 +00:00
|
|
|
}
|
|
|
|
#endif
|
2013-10-02 16:42:21 +00:00
|
|
|
|
2014-09-30 19:18:44 +00:00
|
|
|
/** Access methods that are only to be used within Skia code. */
|
|
|
|
inline GrTexturePriv texturePriv();
|
|
|
|
inline const GrTexturePriv texturePriv() const;
|
2012-06-04 20:05:28 +00:00
|
|
|
|
2011-04-05 21:16:14 +00:00
|
|
|
protected:
|
2016-03-11 18:07:37 +00:00
|
|
|
GrTexture(GrGpu*, LifeCycle, const GrSurfaceDesc&, GrSLType, bool wasMipMapDataProvided);
|
2014-05-09 20:46:48 +00:00
|
|
|
|
2012-06-04 12:48:45 +00:00
|
|
|
void validateDesc() const;
|
|
|
|
|
2014-05-09 17:37:55 +00:00
|
|
|
private:
|
2015-03-26 01:17:31 +00:00
|
|
|
size_t onGpuMemorySize() const override;
|
2014-05-09 20:46:48 +00:00
|
|
|
void dirtyMipMaps(bool mipMapsDirty);
|
|
|
|
|
|
|
|
enum MipMapsStatus {
|
|
|
|
kNotAllocated_MipMapsStatus,
|
|
|
|
kAllocated_MipMapsStatus,
|
|
|
|
kValid_MipMapsStatus
|
|
|
|
};
|
|
|
|
|
2016-03-11 18:07:37 +00:00
|
|
|
GrSLType fSamplerType;
|
2014-09-30 19:18:44 +00:00
|
|
|
MipMapsStatus fMipMapsStatus;
|
2016-03-11 18:07:37 +00:00
|
|
|
int fMaxMipMapLevel;
|
2014-09-30 19:18:44 +00:00
|
|
|
|
|
|
|
friend class GrTexturePriv;
|
2014-05-09 20:46:48 +00:00
|
|
|
|
2014-09-30 19:18:44 +00:00
|
|
|
typedef GrSurface INHERITED;
|
2010-12-22 21:39:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|