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 | #include "GrBackendSurface.h" |
| 9 | |
Greg Daniel | e7d8da4 | 2017-12-04 11:23:19 -0500 | [diff] [blame] | 10 | #include "gl/GrGLUtil.h" |
| 11 | |
Greg Daniel | 9440345 | 2017-04-18 15:52:36 -0400 | [diff] [blame] | 12 | #ifdef SK_VULKAN |
| 13 | #include "vk/GrVkTypes.h" |
| 14 | #include "vk/GrVkUtil.h" |
Greg Daniel | 7ef28f3 | 2017-04-20 16:41:55 +0000 | [diff] [blame] | 15 | #endif |
| 16 | |
Robert Phillips | fcd5fdd | 2017-06-14 01:43:29 +0000 | [diff] [blame] | 17 | #ifdef SK_VULKAN |
Greg Daniel | 9440345 | 2017-04-18 15:52:36 -0400 | [diff] [blame] | 18 | GrBackendTexture::GrBackendTexture(int width, |
| 19 | int height, |
Greg Daniel | 207282e | 2017-04-26 13:29:21 -0400 | [diff] [blame] | 20 | const GrVkImageInfo& vkInfo) |
Greg Daniel | 9440345 | 2017-04-18 15:52:36 -0400 | [diff] [blame] | 21 | : fWidth(width) |
| 22 | , fHeight(height) |
Robert Phillips | fcd5fdd | 2017-06-14 01:43:29 +0000 | [diff] [blame] | 23 | , fConfig(GrVkFormatToPixelConfig(vkInfo.fFormat)) |
Chris Dalton | 3b51df1 | 2017-11-27 14:33:06 -0700 | [diff] [blame] | 24 | , fMipMapped(GrMipMapped(vkInfo.fLevelCount > 1)) |
Greg Daniel | 9440345 | 2017-04-18 15:52:36 -0400 | [diff] [blame] | 25 | , fBackend(kVulkan_GrBackend) |
| 26 | , fVkInfo(vkInfo) {} |
Robert Phillips | fcd5fdd | 2017-06-14 01:43:29 +0000 | [diff] [blame] | 27 | #endif |
Greg Daniel | 9440345 | 2017-04-18 15:52:36 -0400 | [diff] [blame] | 28 | |
| 29 | GrBackendTexture::GrBackendTexture(int width, |
| 30 | int height, |
| 31 | GrPixelConfig config, |
Greg Daniel | 207282e | 2017-04-26 13:29:21 -0400 | [diff] [blame] | 32 | const GrGLTextureInfo& glInfo) |
Greg Daniel | 177e695 | 2017-10-12 12:27:11 -0400 | [diff] [blame] | 33 | : GrBackendTexture(width, height, config, GrMipMapped::kNo, glInfo) {} |
| 34 | |
| 35 | GrBackendTexture::GrBackendTexture(int width, |
| 36 | int height, |
| 37 | GrPixelConfig config, |
| 38 | GrMipMapped mipMapped, |
| 39 | const GrGLTextureInfo& glInfo) |
Greg Daniel | 9440345 | 2017-04-18 15:52:36 -0400 | [diff] [blame] | 40 | : fWidth(width) |
| 41 | , fHeight(height) |
| 42 | , fConfig(config) |
Greg Daniel | 177e695 | 2017-10-12 12:27:11 -0400 | [diff] [blame] | 43 | , fMipMapped(mipMapped) |
Greg Daniel | 9440345 | 2017-04-18 15:52:36 -0400 | [diff] [blame] | 44 | , fBackend(kOpenGL_GrBackend) |
| 45 | , fGLInfo(glInfo) {} |
| 46 | |
Brian Salomon | 8fe2427 | 2017-07-07 12:56:11 -0400 | [diff] [blame] | 47 | GrBackendTexture::GrBackendTexture(int width, |
| 48 | int height, |
Greg Daniel | e7d8da4 | 2017-12-04 11:23:19 -0500 | [diff] [blame] | 49 | GrMipMapped mipMapped, |
| 50 | const GrGLTextureInfo& glInfo) |
| 51 | : fWidth(width) |
| 52 | , fHeight(height) |
| 53 | , fConfig(GrGLSizedFormatToPixelConfig(glInfo.fFormat)) |
| 54 | , fMipMapped(mipMapped) |
| 55 | , fBackend(kOpenGL_GrBackend) |
| 56 | , fGLInfo(glInfo) {} |
| 57 | |
| 58 | GrBackendTexture::GrBackendTexture(int width, |
| 59 | int height, |
Brian Salomon | 8fe2427 | 2017-07-07 12:56:11 -0400 | [diff] [blame] | 60 | GrPixelConfig config, |
| 61 | const GrMockTextureInfo& mockInfo) |
Greg Daniel | 177e695 | 2017-10-12 12:27:11 -0400 | [diff] [blame] | 62 | : GrBackendTexture(width, height, config, GrMipMapped::kNo, mockInfo) {} |
| 63 | |
| 64 | GrBackendTexture::GrBackendTexture(int width, |
| 65 | int height, |
| 66 | GrPixelConfig config, |
| 67 | GrMipMapped mipMapped, |
| 68 | const GrMockTextureInfo& mockInfo) |
Brian Salomon | 8fe2427 | 2017-07-07 12:56:11 -0400 | [diff] [blame] | 69 | : fWidth(width) |
| 70 | , fHeight(height) |
| 71 | , fConfig(config) |
Greg Daniel | 177e695 | 2017-10-12 12:27:11 -0400 | [diff] [blame] | 72 | , fMipMapped(mipMapped) |
Brian Salomon | 8fe2427 | 2017-07-07 12:56:11 -0400 | [diff] [blame] | 73 | , fBackend(kMock_GrBackend) |
| 74 | , fMockInfo(mockInfo) {} |
| 75 | |
Robert Phillips | fcd5fdd | 2017-06-14 01:43:29 +0000 | [diff] [blame] | 76 | #ifdef SK_VULKAN |
Greg Daniel | 7ef28f3 | 2017-04-20 16:41:55 +0000 | [diff] [blame] | 77 | const GrVkImageInfo* GrBackendTexture::getVkImageInfo() const { |
Brian Salomon | 8fe2427 | 2017-07-07 12:56:11 -0400 | [diff] [blame] | 78 | if (this->isValid() && kVulkan_GrBackend == fBackend) { |
Greg Daniel | 207282e | 2017-04-26 13:29:21 -0400 | [diff] [blame] | 79 | return &fVkInfo; |
Greg Daniel | 9440345 | 2017-04-18 15:52:36 -0400 | [diff] [blame] | 80 | } |
| 81 | return nullptr; |
| 82 | } |
Robert Phillips | fcd5fdd | 2017-06-14 01:43:29 +0000 | [diff] [blame] | 83 | #endif |
Greg Daniel | 9440345 | 2017-04-18 15:52:36 -0400 | [diff] [blame] | 84 | |
Greg Daniel | 7ef28f3 | 2017-04-20 16:41:55 +0000 | [diff] [blame] | 85 | const GrGLTextureInfo* GrBackendTexture::getGLTextureInfo() const { |
Brian Salomon | 8fe2427 | 2017-07-07 12:56:11 -0400 | [diff] [blame] | 86 | if (this->isValid() && kOpenGL_GrBackend == fBackend) { |
Greg Daniel | 207282e | 2017-04-26 13:29:21 -0400 | [diff] [blame] | 87 | return &fGLInfo; |
Greg Daniel | 9440345 | 2017-04-18 15:52:36 -0400 | [diff] [blame] | 88 | } |
| 89 | return nullptr; |
| 90 | } |
| 91 | |
Brian Salomon | 8fe2427 | 2017-07-07 12:56:11 -0400 | [diff] [blame] | 92 | const GrMockTextureInfo* GrBackendTexture::getMockTextureInfo() const { |
| 93 | if (this->isValid() && kMock_GrBackend == fBackend) { |
| 94 | return &fMockInfo; |
| 95 | } |
| 96 | return nullptr; |
| 97 | } |
| 98 | |
Greg Daniel | 9440345 | 2017-04-18 15:52:36 -0400 | [diff] [blame] | 99 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 100 | |
Robert Phillips | fcd5fdd | 2017-06-14 01:43:29 +0000 | [diff] [blame] | 101 | #ifdef SK_VULKAN |
Greg Daniel | 9440345 | 2017-04-18 15:52:36 -0400 | [diff] [blame] | 102 | GrBackendRenderTarget::GrBackendRenderTarget(int width, |
| 103 | int height, |
| 104 | int sampleCnt, |
| 105 | int stencilBits, |
Greg Daniel | bcf612b | 2017-05-01 13:50:58 +0000 | [diff] [blame] | 106 | const GrVkImageInfo& vkInfo) |
Greg Daniel | 9440345 | 2017-04-18 15:52:36 -0400 | [diff] [blame] | 107 | : fWidth(width) |
| 108 | , fHeight(height) |
| 109 | , fSampleCnt(sampleCnt) |
| 110 | , fStencilBits(stencilBits) |
Robert Phillips | fcd5fdd | 2017-06-14 01:43:29 +0000 | [diff] [blame] | 111 | , fConfig(GrVkFormatToPixelConfig(vkInfo.fFormat)) |
Greg Daniel | 9440345 | 2017-04-18 15:52:36 -0400 | [diff] [blame] | 112 | , fBackend(kVulkan_GrBackend) |
| 113 | , fVkInfo(vkInfo) {} |
Robert Phillips | fcd5fdd | 2017-06-14 01:43:29 +0000 | [diff] [blame] | 114 | #endif |
Greg Daniel | 9440345 | 2017-04-18 15:52:36 -0400 | [diff] [blame] | 115 | |
| 116 | GrBackendRenderTarget::GrBackendRenderTarget(int width, |
| 117 | int height, |
| 118 | int sampleCnt, |
| 119 | int stencilBits, |
| 120 | GrPixelConfig config, |
Greg Daniel | bcf612b | 2017-05-01 13:50:58 +0000 | [diff] [blame] | 121 | const GrGLFramebufferInfo& glInfo) |
Greg Daniel | 9440345 | 2017-04-18 15:52:36 -0400 | [diff] [blame] | 122 | : fWidth(width) |
| 123 | , fHeight(height) |
| 124 | , fSampleCnt(sampleCnt) |
| 125 | , fStencilBits(stencilBits) |
| 126 | , fConfig(config) |
| 127 | , fBackend(kOpenGL_GrBackend) |
| 128 | , fGLInfo(glInfo) {} |
| 129 | |
Greg Daniel | faa095e | 2017-12-19 13:15:02 -0500 | [diff] [blame] | 130 | GrBackendRenderTarget::GrBackendRenderTarget(int width, |
| 131 | int height, |
| 132 | int sampleCnt, |
| 133 | int stencilBits, |
| 134 | const GrGLFramebufferInfo& glInfo) |
| 135 | : fWidth(width) |
| 136 | , fHeight(height) |
| 137 | , fSampleCnt(sampleCnt) |
| 138 | , fStencilBits(stencilBits) |
| 139 | , fConfig(GrGLSizedFormatToPixelConfig(glInfo.fFormat)) |
| 140 | , fBackend(kOpenGL_GrBackend) |
| 141 | , fGLInfo(glInfo) {} |
| 142 | |
Robert Phillips | fcd5fdd | 2017-06-14 01:43:29 +0000 | [diff] [blame] | 143 | #ifdef SK_VULKAN |
Greg Daniel | 7ef28f3 | 2017-04-20 16:41:55 +0000 | [diff] [blame] | 144 | const GrVkImageInfo* GrBackendRenderTarget::getVkImageInfo() const { |
Greg Daniel | 9440345 | 2017-04-18 15:52:36 -0400 | [diff] [blame] | 145 | if (kVulkan_GrBackend == fBackend) { |
Greg Daniel | bcf612b | 2017-05-01 13:50:58 +0000 | [diff] [blame] | 146 | return &fVkInfo; |
Greg Daniel | 9440345 | 2017-04-18 15:52:36 -0400 | [diff] [blame] | 147 | } |
| 148 | return nullptr; |
| 149 | } |
Robert Phillips | fcd5fdd | 2017-06-14 01:43:29 +0000 | [diff] [blame] | 150 | #endif |
Greg Daniel | 9440345 | 2017-04-18 15:52:36 -0400 | [diff] [blame] | 151 | |
Greg Daniel | bcf612b | 2017-05-01 13:50:58 +0000 | [diff] [blame] | 152 | const GrGLFramebufferInfo* GrBackendRenderTarget::getGLFramebufferInfo() const { |
Greg Daniel | 9440345 | 2017-04-18 15:52:36 -0400 | [diff] [blame] | 153 | if (kOpenGL_GrBackend == fBackend) { |
Greg Daniel | bcf612b | 2017-05-01 13:50:58 +0000 | [diff] [blame] | 154 | return &fGLInfo; |
Greg Daniel | 9440345 | 2017-04-18 15:52:36 -0400 | [diff] [blame] | 155 | } |
| 156 | return nullptr; |
| 157 | } |
| 158 | |