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 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 12 | #include "include/gpu/GrTexture.h" |
Brian Salomon | e2826ab | 2019-06-04 15:58:31 -0400 | [diff] [blame^] | 13 | #include "include/private/GrGLTypesPriv.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 14 | #include "src/gpu/GrGpu.h" |
| 15 | #include "src/gpu/gl/GrGLUtil.h" |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 16 | |
jvanverth | d1e7287 | 2015-04-20 12:29:37 -0700 | [diff] [blame] | 17 | class GrGLGpu; |
bsalomon@google.com | 5877ffd | 2011-04-11 17:58:48 +0000 | [diff] [blame] | 18 | |
bsalomon | afbf2d6 | 2014-09-30 12:18:44 -0700 | [diff] [blame] | 19 | class GrGLTexture : public GrTexture { |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 20 | public: |
bsalomon | b15b4c1 | 2014-10-29 12:41:57 -0700 | [diff] [blame] | 21 | struct IDDesc { |
bsalomon | 091f60c | 2015-11-10 11:54:56 -0800 | [diff] [blame] | 22 | GrGLTextureInfo fInfo; |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 23 | GrBackendObjectOwnership fOwnership; |
bsalomon@google.com | 5877ffd | 2011-04-11 17:58:48 +0000 | [diff] [blame] | 24 | }; |
Brian Salomon | 7226c23 | 2018-07-30 13:13:17 -0400 | [diff] [blame] | 25 | |
| 26 | static GrTextureType TextureTypeFromTarget(GrGLenum textureTarget); |
| 27 | |
Greg Daniel | 0fc4d2d | 2017-10-12 11:23:36 -0400 | [diff] [blame] | 28 | GrGLTexture(GrGLGpu*, SkBudgeted, const GrSurfaceDesc&, const IDDesc&, GrMipMapsStatus); |
bsalomon@google.com | 5bfc217 | 2011-07-29 20:29:05 +0000 | [diff] [blame] | 29 | |
Greg Daniel | 2d35a1c | 2019-02-01 14:48:10 -0500 | [diff] [blame] | 30 | ~GrGLTexture() override {} |
Greg Daniel | cef213c | 2017-04-21 11:52:27 -0400 | [diff] [blame] | 31 | |
Robert Phillips | b67821d | 2017-12-13 15:00:45 -0500 | [diff] [blame] | 32 | GrBackendTexture getBackendTexture() const override; |
junov@chromium.org | 957ebdd | 2012-06-12 13:58:36 +0000 | [diff] [blame] | 33 | |
Greg Daniel | 4065d45 | 2018-11-16 15:43:41 -0500 | [diff] [blame] | 34 | GrBackendFormat backendFormat() const override; |
| 35 | |
Brian Salomon | e2826ab | 2019-06-04 15:58:31 -0400 | [diff] [blame^] | 36 | // TODO: Remove once clients are no longer calling this. |
| 37 | void textureParamsModified() override { fParameters->invalidate(); } |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 38 | |
Brian Salomon | e2826ab | 2019-06-04 15:58:31 -0400 | [diff] [blame^] | 39 | GrGLTextureParameters* parameters() { return fParameters.get(); } |
commit-bot@chromium.org | 59e16e4 | 2013-07-17 21:39:58 +0000 | [diff] [blame] | 40 | |
Brian Salomon | 60dd8c7 | 2018-07-30 10:24:13 -0400 | [diff] [blame] | 41 | GrGLuint textureID() const { return fID; } |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 42 | |
Brian Salomon | 60dd8c7 | 2018-07-30 10:24:13 -0400 | [diff] [blame] | 43 | GrGLenum target() const; |
bsalomon | 10528f1 | 2015-10-14 12:54:52 -0700 | [diff] [blame] | 44 | |
Brian Salomon | 9bada54 | 2017-06-12 12:09:30 -0400 | [diff] [blame] | 45 | bool hasBaseLevelBeenBoundToFBO() const { return fBaseLevelHasBeenBoundToFBO; } |
| 46 | void baseLevelWasBoundToFBO() { fBaseLevelHasBeenBoundToFBO = true; } |
| 47 | |
Greg Daniel | 177e695 | 2017-10-12 12:27:11 -0400 | [diff] [blame] | 48 | static sk_sp<GrGLTexture> MakeWrapped(GrGLGpu*, const GrSurfaceDesc&, GrMipMapsStatus, |
Brian Salomon | e2826ab | 2019-06-04 15:58:31 -0400 | [diff] [blame^] | 49 | const IDDesc&, sk_sp<GrGLTextureParameters>, |
| 50 | GrWrapCacheable, GrIOType); |
Brian Salomon | 9bada54 | 2017-06-12 12:09:30 -0400 | [diff] [blame] | 51 | |
Eric Karl | af77002 | 2018-03-19 13:04:03 -0700 | [diff] [blame] | 52 | void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const override; |
| 53 | |
bsalomon@google.com | 5877ffd | 2011-04-11 17:58:48 +0000 | [diff] [blame] | 54 | protected: |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 55 | // Constructor for subclasses. |
Brian Salomon | e2826ab | 2019-06-04 15:58:31 -0400 | [diff] [blame^] | 56 | GrGLTexture(GrGLGpu*, const GrSurfaceDesc&, const IDDesc&, sk_sp<GrGLTextureParameters>, |
| 57 | GrMipMapsStatus); |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 58 | |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 59 | // Constructor for instances wrapping backend objects. |
Brian Salomon | e2826ab | 2019-06-04 15:58:31 -0400 | [diff] [blame^] | 60 | GrGLTexture(GrGLGpu*, const GrSurfaceDesc&, GrMipMapsStatus, const IDDesc&, |
| 61 | sk_sp<GrGLTextureParameters>, GrWrapCacheable, GrIOType); |
bsalomon | 37dd331 | 2014-11-03 08:47:23 -0800 | [diff] [blame] | 62 | |
| 63 | void init(const GrSurfaceDesc&, const IDDesc&); |
| 64 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 65 | void onAbandon() override; |
| 66 | void onRelease() override; |
bsalomon@google.com | 8fe7247 | 2011-03-30 21:26:44 +0000 | [diff] [blame] | 67 | |
Eric Karl | 914a36b | 2017-10-12 12:44:50 -0700 | [diff] [blame] | 68 | bool onStealBackendTexture(GrBackendTexture*, SkImage::BackendTextureReleaseProc*) override; |
| 69 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 70 | private: |
Brian Salomon | e2826ab | 2019-06-04 15:58:31 -0400 | [diff] [blame^] | 71 | sk_sp<GrGLTextureParameters> fParameters; |
Brian Salomon | dc82994 | 2018-10-23 16:07:24 -0400 | [diff] [blame] | 72 | GrGLuint fID; |
| 73 | GrGLenum fFormat; |
| 74 | GrBackendObjectOwnership fTextureIDOwnership; |
| 75 | bool fBaseLevelHasBeenBoundToFBO = false; |
Greg Daniel | cef213c | 2017-04-21 11:52:27 -0400 | [diff] [blame] | 76 | |
bsalomon | afbf2d6 | 2014-09-30 12:18:44 -0700 | [diff] [blame] | 77 | typedef GrTexture INHERITED; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 78 | }; |
| 79 | |
| 80 | #endif |