blob: ddba94065be2600847422bc887b89db46f62f9a0 [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
bsalomon@google.comb8670992012-07-25 21:27:09 +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; }
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:
bsalomon5236cf42015-01-14 10:42:08 -080048 GrTexture(GrGpu*, LifeCycle, const GrSurfaceDesc&);
commit-bot@chromium.orge49157f2014-05-09 20:46:48 +000049
commit-bot@chromium.orge49157f2014-05-09 20:46:48 +000050 void validateDesc() const;
51
52private:
mtklein36352bf2015-03-25 18:17:31 -070053 size_t onGpuMemorySize() const override;
commit-bot@chromium.orge49157f2014-05-09 20:46:48 +000054 void dirtyMipMaps(bool mipMapsDirty);
55
commit-bot@chromium.org11c6b392014-05-05 19:09:13 +000056 enum MipMapsStatus {
57 kNotAllocated_MipMapsStatus,
58 kAllocated_MipMapsStatus,
59 kValid_MipMapsStatus
60 };
61
bsalomonafbf2d62014-09-30 12:18:44 -070062 MipMapsStatus fMipMapsStatus;
63 // These two shift a fixed-point value into normalized coordinates
64 // for this texture if the texture is power of two sized.
65 int fShiftFixedX;
66 int fShiftFixedY;
reed@google.comac10a2d2010-12-22 21:39:39 +000067
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