blob: 8fa0db95874ae4e774bb14258a2a521921362802 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
reed@google.comac10a2d2010-12-22 21:39:39 +00002/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00003 * 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.
reed@google.comac10a2d2010-12-22 21:39:39 +00007 */
8
reed@google.comac10a2d2010-12-22 21:39:39 +00009#ifndef GrTexture_DEFINED
10#define GrTexture_DEFINED
11
robertphillips@google.com7d501ab2012-06-21 21:09:06 +000012#include "GrSurface.h"
Brian Salomon4d53c442016-11-04 11:54:32 -040013#include "GrTextureParams.h"
bsalomonc44be0e2014-07-25 07:32:33 -070014#include "SkPoint.h"
15#include "SkRefCnt.h"
reed@google.comac10a2d2010-12-22 21:39:39 +000016
bsalomonafbf2d62014-09-30 12:18:44 -070017class GrTexturePriv;
reed@google.comac10a2d2010-12-22 21:39:39 +000018
bsalomon37dd3312014-11-03 08:47:23 -080019class GrTexture : virtual public GrSurface {
reed@google.comac10a2d2010-12-22 21:39:39 +000020public:
mtklein36352bf2015-03-25 18:17:31 -070021 GrTexture* asTexture() override { return this; }
22 const GrTexture* asTexture() const override { return this; }
commit-bot@chromium.org59e7d232014-05-09 18:02:51 +000023
24 /**
commit-bot@chromium.org59e7d232014-05-09 18:02:51 +000025 * 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;
reed@google.comac10a2d2010-12-22 21:39:39 +000029
junov@chromium.org957ebdd2012-06-12 13:58:36 +000030 /**
commit-bot@chromium.orge49157f2014-05-09 20:46:48 +000031 * This function indicates that the texture parameters (wrap mode, filtering, ...) have been
32 * changed externally to Skia.
junov@chromium.org957ebdd2012-06-12 13:58:36 +000033 */
commit-bot@chromium.orge49157f2014-05-09 20:46:48 +000034 virtual void textureParamsModified() = 0;
commit-bot@chromium.orge49157f2014-05-09 20:46:48 +000035
commit-bot@chromium.org59e7d232014-05-09 18:02:51 +000036#ifdef SK_DEBUG
37 void validate() const {
38 this->INHERITED::validate();
commit-bot@chromium.org59e7d232014-05-09 18:02:51 +000039 this->validateDesc();
40 }
41#endif
42
bsalomonafbf2d62014-09-30 12:18:44 -070043 /** Access methods that are only to be used within Skia code. */
44 inline GrTexturePriv texturePriv();
45 inline const GrTexturePriv texturePriv() const;
commit-bot@chromium.orge49157f2014-05-09 20:46:48 +000046
47protected:
Brian Salomon4d53c442016-11-04 11:54:32 -040048 GrTexture(GrGpu*, const GrSurfaceDesc&, GrSLType samplerType,
49 GrTextureParams::FilterMode highestFilterMode, bool wasMipMapDataProvided);
commit-bot@chromium.orge49157f2014-05-09 20:46:48 +000050
commit-bot@chromium.orge49157f2014-05-09 20:46:48 +000051 void validateDesc() const;
52
53private:
kkinnunen2e6055b2016-04-22 01:48:29 -070054 void computeScratchKey(GrScratchKey*) const override;
mtklein36352bf2015-03-25 18:17:31 -070055 size_t onGpuMemorySize() const override;
brianosmanfe199872016-06-13 07:59:48 -070056 void dirtyMipMaps(bool mipMapsDirty);
commit-bot@chromium.orge49157f2014-05-09 20:46:48 +000057
commit-bot@chromium.org11c6b392014-05-05 19:09:13 +000058 enum MipMapsStatus {
59 kNotAllocated_MipMapsStatus,
60 kAllocated_MipMapsStatus,
61 kValid_MipMapsStatus
62 };
63
Brian Salomon4d53c442016-11-04 11:54:32 -040064 GrSLType fSamplerType;
65 GrTextureParams::FilterMode fHighestFilterMode;
66 MipMapsStatus fMipMapsStatus;
67 int fMaxMipMapLevel;
68 SkSourceGammaTreatment fGammaTreatment;
bsalomonafbf2d62014-09-30 12:18:44 -070069 friend class GrTexturePriv;
70
71 typedef GrSurface INHERITED;
reed@google.comac10a2d2010-12-22 21:39:39 +000072};
73
74#endif