blob: 211f1937da72b32740e769014a7735ee89b3fadd [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"
bsalomonc44be0e2014-07-25 07:32:33 -070013#include "SkPoint.h"
14#include "SkRefCnt.h"
reed@google.comac10a2d2010-12-22 21:39:39 +000015
Ben Wagnerce4d04a2016-11-06 12:46:37 +000016class GrTextureParams;
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; }
Ben Wagnerce4d04a2016-11-06 12:46:37 +000023 GrSLType samplerType() const { return fSamplerType; }
commit-bot@chromium.org59e7d232014-05-09 18:02:51 +000024
25 /**
commit-bot@chromium.org59e7d232014-05-09 18:02:51 +000026 * Return the native ID or handle to the texture, depending on the
27 * platform. e.g. on OpenGL, return the texture ID.
28 */
29 virtual GrBackendObject getTextureHandle() const = 0;
reed@google.comac10a2d2010-12-22 21:39:39 +000030
junov@chromium.org957ebdd2012-06-12 13:58:36 +000031 /**
commit-bot@chromium.orge49157f2014-05-09 20:46:48 +000032 * This function indicates that the texture parameters (wrap mode, filtering, ...) have been
33 * changed externally to Skia.
junov@chromium.org957ebdd2012-06-12 13:58:36 +000034 */
commit-bot@chromium.orge49157f2014-05-09 20:46:48 +000035 virtual void textureParamsModified() = 0;
commit-bot@chromium.orge49157f2014-05-09 20:46:48 +000036
commit-bot@chromium.org59e7d232014-05-09 18:02:51 +000037#ifdef SK_DEBUG
38 void validate() const {
39 this->INHERITED::validate();
commit-bot@chromium.org59e7d232014-05-09 18:02:51 +000040 this->validateDesc();
41 }
42#endif
43
bsalomonafbf2d62014-09-30 12:18:44 -070044 /** Access methods that are only to be used within Skia code. */
45 inline GrTexturePriv texturePriv();
46 inline const GrTexturePriv texturePriv() const;
commit-bot@chromium.orge49157f2014-05-09 20:46:48 +000047
48protected:
Ben Wagnerce4d04a2016-11-06 12:46:37 +000049 GrTexture(GrGpu*, const GrSurfaceDesc&, GrSLType, 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
Ben Wagnerce4d04a2016-11-06 12:46:37 +000064 GrSLType fSamplerType;
65 MipMapsStatus fMipMapsStatus;
66 int fMaxMipMapLevel;
67 SkSourceGammaTreatment fGammaTreatment;
68
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