blob: 7b8cd908f29cb920e668222580dd2345b2ce9949 [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"
Greg Daniel0fc4d2d2017-10-12 11:23:36 -040016#include "../private/GrTypesPriv.h"
reed@google.comac10a2d2010-12-22 21:39:39 +000017
bsalomonafbf2d62014-09-30 12:18:44 -070018class GrTexturePriv;
reed@google.comac10a2d2010-12-22 21:39:39 +000019
bsalomon37dd3312014-11-03 08:47:23 -080020class GrTexture : virtual public GrSurface {
reed@google.comac10a2d2010-12-22 21:39:39 +000021public:
mtklein36352bf2015-03-25 18:17:31 -070022 GrTexture* asTexture() override { return this; }
23 const GrTexture* asTexture() const override { return this; }
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 }
41#endif
42
Greg Danielcef213c2017-04-21 11:52:27 -040043 // These match the definitions in SkImage, for whence they came
44 typedef void* ReleaseCtx;
45 typedef void (*ReleaseProc)(ReleaseCtx);
46
47 virtual void setRelease(ReleaseProc proc, ReleaseCtx ctx) = 0;
48
bsalomonafbf2d62014-09-30 12:18:44 -070049 /** Access methods that are only to be used within Skia code. */
50 inline GrTexturePriv texturePriv();
51 inline const GrTexturePriv texturePriv() const;
commit-bot@chromium.orge49157f2014-05-09 20:46:48 +000052
53protected:
Brian Salomon739c5bf2016-11-07 09:53:44 -050054 GrTexture(GrGpu*, const GrSurfaceDesc&, GrSLType samplerType,
Greg Daniel0fc4d2d2017-10-12 11:23:36 -040055 GrSamplerState::Filter highestFilterMode, GrMipMapsStatus);
commit-bot@chromium.orge49157f2014-05-09 20:46:48 +000056
commit-bot@chromium.orge49157f2014-05-09 20:46:48 +000057private:
kkinnunen2e6055b2016-04-22 01:48:29 -070058 void computeScratchKey(GrScratchKey*) const override;
mtklein36352bf2015-03-25 18:17:31 -070059 size_t onGpuMemorySize() const override;
Greg Daniel0fc4d2d2017-10-12 11:23:36 -040060 void markMipMapsDirty();
61 void markMipMapsClean();
commit-bot@chromium.org11c6b392014-05-05 19:09:13 +000062
Brian Osman7b8400d2016-11-08 17:08:54 -050063 GrSLType fSamplerType;
Brian Salomon2bbdcc42017-09-07 12:36:34 -040064 GrSamplerState::Filter fHighestFilterMode;
Greg Daniel0fc4d2d2017-10-12 11:23:36 -040065 GrMipMapsStatus fMipMapsStatus;
Brian Osman7b8400d2016-11-08 17:08:54 -050066 int fMaxMipMapLevel;
67 SkDestinationSurfaceColorMode fMipColorMode;
bsalomonafbf2d62014-09-30 12:18:44 -070068 friend class GrTexturePriv;
69
70 typedef GrSurface INHERITED;
reed@google.comac10a2d2010-12-22 21:39:39 +000071};
72
73#endif