epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 2 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 3 | * 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.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 9 | #ifndef GrTexture_DEFINED |
| 10 | #define GrTexture_DEFINED |
| 11 | |
robertphillips@google.com | 7d501ab | 2012-06-21 21:09:06 +0000 | [diff] [blame] | 12 | #include "GrSurface.h" |
Brian Salomon | 514baff | 2016-11-17 15:17:07 -0500 | [diff] [blame] | 13 | #include "GrSamplerParams.h" |
bsalomon | c44be0e | 2014-07-25 07:32:33 -0700 | [diff] [blame] | 14 | #include "SkPoint.h" |
| 15 | #include "SkRefCnt.h" |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 16 | |
bsalomon | afbf2d6 | 2014-09-30 12:18:44 -0700 | [diff] [blame] | 17 | class GrTexturePriv; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 18 | |
bsalomon | 37dd331 | 2014-11-03 08:47:23 -0800 | [diff] [blame] | 19 | class GrTexture : virtual public GrSurface { |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 20 | public: |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 21 | GrTexture* asTexture() override { return this; } |
| 22 | const GrTexture* asTexture() const override { return this; } |
commit-bot@chromium.org | 59e7d23 | 2014-05-09 18:02:51 +0000 | [diff] [blame] | 23 | |
| 24 | /** |
commit-bot@chromium.org | 59e7d23 | 2014-05-09 18:02:51 +0000 | [diff] [blame] | 25 | * 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.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 29 | |
junov@chromium.org | 957ebdd | 2012-06-12 13:58:36 +0000 | [diff] [blame] | 30 | /** |
commit-bot@chromium.org | e49157f | 2014-05-09 20:46:48 +0000 | [diff] [blame] | 31 | * This function indicates that the texture parameters (wrap mode, filtering, ...) have been |
| 32 | * changed externally to Skia. |
junov@chromium.org | 957ebdd | 2012-06-12 13:58:36 +0000 | [diff] [blame] | 33 | */ |
commit-bot@chromium.org | e49157f | 2014-05-09 20:46:48 +0000 | [diff] [blame] | 34 | virtual void textureParamsModified() = 0; |
commit-bot@chromium.org | e49157f | 2014-05-09 20:46:48 +0000 | [diff] [blame] | 35 | |
commit-bot@chromium.org | 59e7d23 | 2014-05-09 18:02:51 +0000 | [diff] [blame] | 36 | #ifdef SK_DEBUG |
| 37 | void validate() const { |
| 38 | this->INHERITED::validate(); |
Greg Daniel | 4b30a96 | 2017-05-18 18:13:40 +0000 | [diff] [blame] | 39 | this->validateDesc(); |
commit-bot@chromium.org | 59e7d23 | 2014-05-09 18:02:51 +0000 | [diff] [blame] | 40 | } |
| 41 | #endif |
| 42 | |
Greg Daniel | cef213c | 2017-04-21 11:52:27 -0400 | [diff] [blame] | 43 | // 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 | |
bsalomon | afbf2d6 | 2014-09-30 12:18:44 -0700 | [diff] [blame] | 49 | /** Access methods that are only to be used within Skia code. */ |
| 50 | inline GrTexturePriv texturePriv(); |
| 51 | inline const GrTexturePriv texturePriv() const; |
commit-bot@chromium.org | e49157f | 2014-05-09 20:46:48 +0000 | [diff] [blame] | 52 | |
| 53 | protected: |
Brian Salomon | 739c5bf | 2016-11-07 09:53:44 -0500 | [diff] [blame] | 54 | GrTexture(GrGpu*, const GrSurfaceDesc&, GrSLType samplerType, |
Brian Salomon | 514baff | 2016-11-17 15:17:07 -0500 | [diff] [blame] | 55 | GrSamplerParams::FilterMode highestFilterMode, bool wasMipMapDataProvided); |
commit-bot@chromium.org | e49157f | 2014-05-09 20:46:48 +0000 | [diff] [blame] | 56 | |
Greg Daniel | 4b30a96 | 2017-05-18 18:13:40 +0000 | [diff] [blame] | 57 | void validateDesc() const; |
| 58 | |
commit-bot@chromium.org | e49157f | 2014-05-09 20:46:48 +0000 | [diff] [blame] | 59 | private: |
kkinnunen | 2e6055b | 2016-04-22 01:48:29 -0700 | [diff] [blame] | 60 | void computeScratchKey(GrScratchKey*) const override; |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 61 | size_t onGpuMemorySize() const override; |
brianosman | fe19987 | 2016-06-13 07:59:48 -0700 | [diff] [blame] | 62 | void dirtyMipMaps(bool mipMapsDirty); |
commit-bot@chromium.org | e49157f | 2014-05-09 20:46:48 +0000 | [diff] [blame] | 63 | |
commit-bot@chromium.org | 11c6b39 | 2014-05-05 19:09:13 +0000 | [diff] [blame] | 64 | enum MipMapsStatus { |
| 65 | kNotAllocated_MipMapsStatus, |
| 66 | kAllocated_MipMapsStatus, |
| 67 | kValid_MipMapsStatus |
| 68 | }; |
| 69 | |
Brian Osman | 7b8400d | 2016-11-08 17:08:54 -0500 | [diff] [blame] | 70 | GrSLType fSamplerType; |
Brian Salomon | 514baff | 2016-11-17 15:17:07 -0500 | [diff] [blame] | 71 | GrSamplerParams::FilterMode fHighestFilterMode; |
Brian Osman | 7b8400d | 2016-11-08 17:08:54 -0500 | [diff] [blame] | 72 | MipMapsStatus fMipMapsStatus; |
| 73 | int fMaxMipMapLevel; |
| 74 | SkDestinationSurfaceColorMode fMipColorMode; |
bsalomon | afbf2d6 | 2014-09-30 12:18:44 -0700 | [diff] [blame] | 75 | friend class GrTexturePriv; |
| 76 | |
| 77 | typedef GrSurface INHERITED; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 78 | }; |
| 79 | |
| 80 | #endif |