blob: c568f933ffd9a1e8be8340600f28b2239d2fd450 [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
Brian Salomon2bbdcc42017-09-07 12:36:34 -040012#include "GrSamplerState.h"
robertphillips@google.com7d501ab2012-06-21 21:09:06 +000013#include "GrSurface.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 }
40#endif
41
Greg Danielcef213c2017-04-21 11:52:27 -040042 // 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
bsalomonafbf2d62014-09-30 12:18:44 -070048 /** Access methods that are only to be used within Skia code. */
49 inline GrTexturePriv texturePriv();
50 inline const GrTexturePriv texturePriv() const;
commit-bot@chromium.orge49157f2014-05-09 20:46:48 +000051
52protected:
Brian Salomon739c5bf2016-11-07 09:53:44 -050053 GrTexture(GrGpu*, const GrSurfaceDesc&, GrSLType samplerType,
Brian Salomon2bbdcc42017-09-07 12:36:34 -040054 GrSamplerState::Filter highestFilterMode, bool wasMipMapDataProvided);
commit-bot@chromium.orge49157f2014-05-09 20:46:48 +000055
commit-bot@chromium.orge49157f2014-05-09 20:46:48 +000056private:
kkinnunen2e6055b2016-04-22 01:48:29 -070057 void computeScratchKey(GrScratchKey*) const override;
mtklein36352bf2015-03-25 18:17:31 -070058 size_t onGpuMemorySize() const override;
brianosmanfe199872016-06-13 07:59:48 -070059 void dirtyMipMaps(bool mipMapsDirty);
commit-bot@chromium.orge49157f2014-05-09 20:46:48 +000060
commit-bot@chromium.org11c6b392014-05-05 19:09:13 +000061 enum MipMapsStatus {
62 kNotAllocated_MipMapsStatus,
63 kAllocated_MipMapsStatus,
64 kValid_MipMapsStatus
65 };
66
Brian Osman7b8400d2016-11-08 17:08:54 -050067 GrSLType fSamplerType;
Brian Salomon2bbdcc42017-09-07 12:36:34 -040068 GrSamplerState::Filter fHighestFilterMode;
Brian Osman7b8400d2016-11-08 17:08:54 -050069 MipMapsStatus fMipMapsStatus;
70 int fMaxMipMapLevel;
71 SkDestinationSurfaceColorMode fMipColorMode;
bsalomonafbf2d62014-09-30 12:18:44 -070072 friend class GrTexturePriv;
73
74 typedef GrSurface INHERITED;
reed@google.comac10a2d2010-12-22 21:39:39 +000075};
76
77#endif