reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 1 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 2 | * Copyright 2011 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 8 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 9 | #ifndef GrGLTexture_DEFINED |
| 10 | #define GrGLTexture_DEFINED |
| 11 | |
tomhudson@google.com | d8f856c | 2012-05-10 12:13:36 +0000 | [diff] [blame] | 12 | #include "GrGpu.h" |
bsalomon | 37dd331 | 2014-11-03 08:47:23 -0800 | [diff] [blame] | 13 | #include "GrTexture.h" |
| 14 | #include "GrGLUtil.h" |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 15 | |
jvanverth | d1e7287 | 2015-04-20 12:29:37 -0700 | [diff] [blame] | 16 | class GrGLGpu; |
bsalomon@google.com | 5877ffd | 2011-04-11 17:58:48 +0000 | [diff] [blame] | 17 | |
bsalomon | afbf2d6 | 2014-09-30 12:18:44 -0700 | [diff] [blame] | 18 | class GrGLTexture : public GrTexture { |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 19 | public: |
bsalomon@google.com | da96ea0 | 2010-12-23 16:53:57 +0000 | [diff] [blame] | 20 | struct TexParams { |
commit-bot@chromium.org | 149f4f5 | 2013-07-26 20:40:06 +0000 | [diff] [blame] | 21 | GrGLenum fMinFilter; |
| 22 | GrGLenum fMagFilter; |
twiz@google.com | 0f31ca7 | 2011-03-18 17:38:11 +0000 | [diff] [blame] | 23 | GrGLenum fWrapS; |
| 24 | GrGLenum fWrapT; |
cblume | 55f2d2d | 2016-02-26 13:20:48 -0800 | [diff] [blame] | 25 | GrGLenum fMaxMipMapLevel; |
bsalomon@google.com | 0a97be2 | 2011-11-08 19:20:57 +0000 | [diff] [blame] | 26 | GrGLenum fSwizzleRGBA[4]; |
brianosman | a635936 | 2016-03-21 06:55:37 -0700 | [diff] [blame] | 27 | GrGLenum fSRGBDecode; |
bsalomon@google.com | 5877ffd | 2011-04-11 17:58:48 +0000 | [diff] [blame] | 28 | void invalidate() { memset(this, 0xff, sizeof(TexParams)); } |
bsalomon@google.com | da96ea0 | 2010-12-23 16:53:57 +0000 | [diff] [blame] | 29 | }; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 30 | |
bsalomon | b15b4c1 | 2014-10-29 12:41:57 -0700 | [diff] [blame] | 31 | struct IDDesc { |
bsalomon | 091f60c | 2015-11-10 11:54:56 -0800 | [diff] [blame] | 32 | GrGLTextureInfo fInfo; |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 33 | GrBackendObjectOwnership fOwnership; |
bsalomon@google.com | 5877ffd | 2011-04-11 17:58:48 +0000 | [diff] [blame] | 34 | }; |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 35 | GrGLTexture(GrGLGpu*, SkBudgeted, const GrSurfaceDesc&, const IDDesc&); |
| 36 | GrGLTexture(GrGLGpu*, SkBudgeted, const GrSurfaceDesc&, const IDDesc&, |
| 37 | bool wasMipMapDataProvided); |
bsalomon@google.com | 5bfc217 | 2011-07-29 20:29:05 +0000 | [diff] [blame] | 38 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 39 | GrBackendObject getTextureHandle() const override; |
junov@chromium.org | 957ebdd | 2012-06-12 13:58:36 +0000 | [diff] [blame] | 40 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 41 | void textureParamsModified() override { fTexParams.invalidate(); } |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 42 | |
commit-bot@chromium.org | 59e16e4 | 2013-07-17 21:39:58 +0000 | [diff] [blame] | 43 | // These functions are used to track the texture parameters associated with the texture. |
bsalomon@google.com | 80d09b9 | 2011-11-05 21:21:13 +0000 | [diff] [blame] | 44 | const TexParams& getCachedTexParams(GrGpu::ResetTimestamp* timestamp) const { |
| 45 | *timestamp = fTexParamsTimestamp; |
| 46 | return fTexParams; |
| 47 | } |
commit-bot@chromium.org | 59e16e4 | 2013-07-17 21:39:58 +0000 | [diff] [blame] | 48 | |
bsalomon@google.com | 80d09b9 | 2011-11-05 21:21:13 +0000 | [diff] [blame] | 49 | void setCachedTexParams(const TexParams& texParams, |
| 50 | GrGpu::ResetTimestamp timestamp) { |
| 51 | fTexParams = texParams; |
| 52 | fTexParamsTimestamp = timestamp; |
| 53 | } |
commit-bot@chromium.org | 59e16e4 | 2013-07-17 21:39:58 +0000 | [diff] [blame] | 54 | |
bsalomon | 091f60c | 2015-11-10 11:54:56 -0800 | [diff] [blame] | 55 | GrGLuint textureID() const { return fInfo.fID; } |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 56 | |
bsalomon | 091f60c | 2015-11-10 11:54:56 -0800 | [diff] [blame] | 57 | GrGLenum target() const { return fInfo.fTarget; } |
bsalomon | 10528f1 | 2015-10-14 12:54:52 -0700 | [diff] [blame] | 58 | |
bungeman | 6bd5284 | 2016-10-27 09:30:08 -0700 | [diff] [blame] | 59 | static sk_sp<GrGLTexture> MakeWrapped(GrGLGpu*, const GrSurfaceDesc&, const IDDesc&); |
bsalomon@google.com | 5877ffd | 2011-04-11 17:58:48 +0000 | [diff] [blame] | 60 | protected: |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 61 | // Constructor for subclasses. |
Ben Wagner | 9c46b68 | 2016-11-06 12:33:22 +0000 | [diff] [blame] | 62 | GrGLTexture(GrGLGpu*, const GrSurfaceDesc&, const IDDesc&); |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 63 | |
| 64 | enum Wrapped { kWrapped }; |
| 65 | // Constructor for instances wrapping backend objects. |
| 66 | GrGLTexture(GrGLGpu*, Wrapped, const GrSurfaceDesc&, const IDDesc&); |
bsalomon | 37dd331 | 2014-11-03 08:47:23 -0800 | [diff] [blame] | 67 | |
| 68 | void init(const GrSurfaceDesc&, const IDDesc&); |
| 69 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 70 | void onAbandon() override; |
| 71 | void onRelease() override; |
ericrk | 0a5fa48 | 2015-09-15 14:16:10 -0700 | [diff] [blame] | 72 | void setMemoryBacking(SkTraceMemoryDump* traceMemoryDump, |
| 73 | const SkString& dumpName) const override; |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 74 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 75 | private: |
bsalomon@google.com | 80d09b9 | 2011-11-05 21:21:13 +0000 | [diff] [blame] | 76 | TexParams fTexParams; |
| 77 | GrGpu::ResetTimestamp fTexParamsTimestamp; |
bsalomon | 091f60c | 2015-11-10 11:54:56 -0800 | [diff] [blame] | 78 | // Holds the texture target and ID. A pointer to this may be shared to external clients for |
| 79 | // direct interaction with the GL object. |
| 80 | GrGLTextureInfo fInfo; |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 81 | GrBackendObjectOwnership fTextureIDOwnership; |
hendrikw | 9a0c7ab | 2014-12-09 14:26:47 -0800 | [diff] [blame] | 82 | |
bsalomon | afbf2d6 | 2014-09-30 12:18:44 -0700 | [diff] [blame] | 83 | typedef GrTexture INHERITED; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 84 | }; |
| 85 | |
| 86 | #endif |