Greg Daniel | 9440345 | 2017-04-18 15:52:36 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017 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. |
| 6 | */ |
| 7 | |
| 8 | #ifndef GrBackendSurface_DEFINED |
| 9 | #define GrBackendSurface_DEFINED |
| 10 | |
| 11 | #include "GrTypes.h" |
Greg Daniel | bcf612b | 2017-05-01 13:50:58 +0000 | [diff] [blame] | 12 | #include "gl/GrGLTypes.h" |
Robert Phillips | fcd5fdd | 2017-06-14 01:43:29 +0000 | [diff] [blame] | 13 | |
| 14 | #ifdef SK_VULKAN |
Greg Daniel | bcf612b | 2017-05-01 13:50:58 +0000 | [diff] [blame] | 15 | #include "vk/GrVkTypes.h" |
Robert Phillips | fcd5fdd | 2017-06-14 01:43:29 +0000 | [diff] [blame] | 16 | #endif |
Greg Daniel | 9440345 | 2017-04-18 15:52:36 -0400 | [diff] [blame] | 17 | |
Brian Salomon | ec045b4 | 2017-07-07 10:34:40 -0400 | [diff] [blame^] | 18 | class SK_API GrBackendTexture { |
Greg Daniel | 9440345 | 2017-04-18 15:52:36 -0400 | [diff] [blame] | 19 | public: |
| 20 | GrBackendTexture(int width, |
| 21 | int height, |
Robert Phillips | fad9e3f | 2017-06-13 22:16:08 +0000 | [diff] [blame] | 22 | GrPixelConfig config, |
| 23 | const GrGLTextureInfo& glInfo); |
Greg Daniel | c0f8e42 | 2017-06-13 13:47:53 -0400 | [diff] [blame] | 24 | |
Robert Phillips | fcd5fdd | 2017-06-14 01:43:29 +0000 | [diff] [blame] | 25 | #ifdef SK_VULKAN |
| 26 | GrBackendTexture(int width, |
| 27 | int height, |
| 28 | const GrVkImageInfo& vkInfo); |
| 29 | #endif |
| 30 | |
Greg Daniel | 9440345 | 2017-04-18 15:52:36 -0400 | [diff] [blame] | 31 | int width() const { return fWidth; } |
| 32 | int height() const { return fHeight; } |
| 33 | GrPixelConfig config() const { return fConfig; } |
| 34 | GrBackend backend() const {return fBackend; } |
| 35 | |
Robert Phillips | fad9e3f | 2017-06-13 22:16:08 +0000 | [diff] [blame] | 36 | // If the backend API is GL, this returns a pointer to the GrGLTextureInfo struct. Otherwise |
| 37 | // it returns nullptr. |
| 38 | const GrGLTextureInfo* getGLTextureInfo() const; |
Greg Daniel | c0f8e42 | 2017-06-13 13:47:53 -0400 | [diff] [blame] | 39 | |
Robert Phillips | fcd5fdd | 2017-06-14 01:43:29 +0000 | [diff] [blame] | 40 | #ifdef SK_VULKAN |
| 41 | // If the backend API is Vulkan, this returns a pointer to the GrVkImageInfo struct. Otherwise |
| 42 | // it returns nullptr. |
| 43 | const GrVkImageInfo* getVkImageInfo() const; |
| 44 | #endif |
| 45 | |
Greg Daniel | 9440345 | 2017-04-18 15:52:36 -0400 | [diff] [blame] | 46 | private: |
| 47 | // Temporary constructor which can be used to convert from a GrBackendTextureDesc. |
| 48 | GrBackendTexture(const GrBackendTextureDesc& desc, GrBackend backend); |
| 49 | |
| 50 | // Friending for access to above constructor taking a GrBackendTextureDesc |
| 51 | friend class SkImage; |
| 52 | friend class SkSurface; |
| 53 | |
| 54 | int fWidth; //<! width in pixels |
| 55 | int fHeight; //<! height in pixels |
| 56 | GrPixelConfig fConfig; |
| 57 | GrBackend fBackend; |
| 58 | |
| 59 | union { |
Robert Phillips | fad9e3f | 2017-06-13 22:16:08 +0000 | [diff] [blame] | 60 | GrGLTextureInfo fGLInfo; |
Robert Phillips | fcd5fdd | 2017-06-14 01:43:29 +0000 | [diff] [blame] | 61 | #ifdef SK_VULKAN |
| 62 | GrVkImageInfo fVkInfo; |
| 63 | #endif |
Greg Daniel | 9440345 | 2017-04-18 15:52:36 -0400 | [diff] [blame] | 64 | }; |
| 65 | }; |
| 66 | |
Brian Salomon | ec045b4 | 2017-07-07 10:34:40 -0400 | [diff] [blame^] | 67 | class SK_API GrBackendRenderTarget { |
Greg Daniel | 9440345 | 2017-04-18 15:52:36 -0400 | [diff] [blame] | 68 | public: |
| 69 | GrBackendRenderTarget(int width, |
| 70 | int height, |
| 71 | int sampleCnt, |
| 72 | int stencilBits, |
Robert Phillips | fcd5fdd | 2017-06-14 01:43:29 +0000 | [diff] [blame] | 73 | GrPixelConfig config, |
| 74 | const GrGLFramebufferInfo& glInfo); |
Greg Daniel | 9440345 | 2017-04-18 15:52:36 -0400 | [diff] [blame] | 75 | |
Robert Phillips | fcd5fdd | 2017-06-14 01:43:29 +0000 | [diff] [blame] | 76 | #ifdef SK_VULKAN |
Greg Daniel | 9440345 | 2017-04-18 15:52:36 -0400 | [diff] [blame] | 77 | GrBackendRenderTarget(int width, |
| 78 | int height, |
| 79 | int sampleCnt, |
| 80 | int stencilBits, |
Robert Phillips | fcd5fdd | 2017-06-14 01:43:29 +0000 | [diff] [blame] | 81 | const GrVkImageInfo& vkInfo); |
| 82 | #endif |
Greg Daniel | 9440345 | 2017-04-18 15:52:36 -0400 | [diff] [blame] | 83 | |
| 84 | int width() const { return fWidth; } |
| 85 | int height() const { return fHeight; } |
| 86 | int sampleCnt() const { return fSampleCnt; } |
| 87 | int stencilBits() const { return fStencilBits; } |
| 88 | GrPixelConfig config() const { return fConfig; } |
| 89 | GrBackend backend() const {return fBackend; } |
| 90 | |
Robert Phillips | fad9e3f | 2017-06-13 22:16:08 +0000 | [diff] [blame] | 91 | // If the backend API is GL, this returns a pointer to the GrGLFramebufferInfo struct. Otherwise |
| 92 | // it returns nullptr. |
| 93 | const GrGLFramebufferInfo* getGLFramebufferInfo() const; |
Greg Daniel | c0f8e42 | 2017-06-13 13:47:53 -0400 | [diff] [blame] | 94 | |
Robert Phillips | fcd5fdd | 2017-06-14 01:43:29 +0000 | [diff] [blame] | 95 | #ifdef SK_VULKAN |
| 96 | // If the backend API is Vulkan, this returns a pointer to the GrVkImageInfo struct. Otherwise |
| 97 | // it returns nullptr |
| 98 | const GrVkImageInfo* getVkImageInfo() const; |
| 99 | #endif |
| 100 | |
Greg Daniel | 9440345 | 2017-04-18 15:52:36 -0400 | [diff] [blame] | 101 | private: |
| 102 | // Temporary constructor which can be used to convert from a GrBackendRenderTargetDesc. |
| 103 | GrBackendRenderTarget(const GrBackendRenderTargetDesc& desc, GrBackend backend); |
| 104 | |
| 105 | // Friending for access to above constructor taking a GrBackendTextureDesc |
| 106 | friend class SkSurface; |
| 107 | |
| 108 | int fWidth; //<! width in pixels |
| 109 | int fHeight; //<! height in pixels |
| 110 | |
| 111 | int fSampleCnt; |
| 112 | int fStencilBits; |
| 113 | GrPixelConfig fConfig; |
| 114 | |
| 115 | GrBackend fBackend; |
| 116 | |
| 117 | union { |
Robert Phillips | fad9e3f | 2017-06-13 22:16:08 +0000 | [diff] [blame] | 118 | GrGLFramebufferInfo fGLInfo; |
Robert Phillips | fcd5fdd | 2017-06-14 01:43:29 +0000 | [diff] [blame] | 119 | #ifdef SK_VULKAN |
| 120 | GrVkImageInfo fVkInfo; |
| 121 | #endif |
Greg Daniel | 9440345 | 2017-04-18 15:52:36 -0400 | [diff] [blame] | 122 | }; |
| 123 | }; |
| 124 | |
| 125 | #endif |
| 126 | |