Stan Iliev | 7e910df | 2017-06-02 10:29:21 -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 | */ |
Stan Iliev | 7e910df | 2017-06-02 10:29:21 -0400 | [diff] [blame] | 7 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 8 | #include "include/core/SkTypes.h" |
Derek Sollenberger | 7a86987 | 2017-06-27 15:37:25 -0400 | [diff] [blame] | 9 | |
| 10 | #if defined(SK_BUILD_FOR_ANDROID) && __ANDROID_API__ >= 26 |
Stan Iliev | 7e910df | 2017-06-02 10:29:21 -0400 | [diff] [blame] | 11 | #define GL_GLEXT_PROTOTYPES |
| 12 | #define EGL_EGLEXT_PROTOTYPES |
Greg Daniel | 54bfb18 | 2018-11-20 17:12:36 -0500 | [diff] [blame] | 13 | |
Greg Daniel | 54bfb18 | 2018-11-20 17:12:36 -0500 | [diff] [blame] | 14 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 15 | #include "src/gpu/GrAHardwareBufferImageGenerator.h" |
Stan Iliev | 7e910df | 2017-06-02 10:29:21 -0400 | [diff] [blame] | 16 | |
Derek Sollenberger | 7a86987 | 2017-06-27 15:37:25 -0400 | [diff] [blame] | 17 | #include <android/hardware_buffer.h> |
| 18 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 19 | #include "include/gpu/GrBackendSurface.h" |
| 20 | #include "include/gpu/GrContext.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 21 | #include "include/gpu/gl/GrGLTypes.h" |
| 22 | #include "include/private/GrRecordingContext.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 23 | #include "src/core/SkExchange.h" |
Ben Wagner | 21bca28 | 2019-05-15 10:15:52 -0400 | [diff] [blame] | 24 | #include "src/core/SkMessageBus.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 25 | #include "src/gpu/GrAHardwareBufferUtils.h" |
| 26 | #include "src/gpu/GrContextPriv.h" |
| 27 | #include "src/gpu/GrProxyProvider.h" |
| 28 | #include "src/gpu/GrRecordingContextPriv.h" |
| 29 | #include "src/gpu/GrResourceCache.h" |
| 30 | #include "src/gpu/GrResourceProvider.h" |
| 31 | #include "src/gpu/GrResourceProviderPriv.h" |
Greg Daniel | 456f9b5 | 2020-03-05 19:14:18 +0000 | [diff] [blame] | 32 | #include "src/gpu/GrTexture.h" |
Greg Daniel | f91aeb2 | 2019-06-18 09:58:02 -0400 | [diff] [blame] | 33 | #include "src/gpu/GrTextureProxy.h" |
Brian Salomon | bc074a6 | 2020-03-18 10:06:13 -0400 | [diff] [blame] | 34 | #include "src/gpu/SkGr.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 35 | #include "src/gpu/gl/GrGLDefines.h" |
Stan Iliev | 7e910df | 2017-06-02 10:29:21 -0400 | [diff] [blame] | 36 | |
| 37 | #include <EGL/egl.h> |
| 38 | #include <EGL/eglext.h> |
| 39 | #include <GLES/gl.h> |
| 40 | #include <GLES/glext.h> |
| 41 | |
Greg Daniel | 637c06a | 2018-09-12 09:44:25 -0400 | [diff] [blame] | 42 | #ifdef SK_VULKAN |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 43 | #include "include/gpu/vk/GrVkExtensions.h" |
| 44 | #include "src/gpu/vk/GrVkGpu.h" |
Greg Daniel | 637c06a | 2018-09-12 09:44:25 -0400 | [diff] [blame] | 45 | #endif |
| 46 | |
Stan Iliev | c01b5c7 | 2018-08-28 10:18:19 -0400 | [diff] [blame] | 47 | #define PROT_CONTENT_EXT_STR "EGL_EXT_protected_content" |
| 48 | #define EGL_PROTECTED_CONTENT_EXT 0x32C0 |
| 49 | |
Stan Iliev | 7e910df | 2017-06-02 10:29:21 -0400 | [diff] [blame] | 50 | std::unique_ptr<SkImageGenerator> GrAHardwareBufferImageGenerator::Make( |
Stan Iliev | 505dd57 | 2018-09-13 14:20:03 -0400 | [diff] [blame] | 51 | AHardwareBuffer* graphicBuffer, SkAlphaType alphaType, sk_sp<SkColorSpace> colorSpace, |
| 52 | GrSurfaceOrigin surfaceOrigin) { |
Stan Iliev | 7e910df | 2017-06-02 10:29:21 -0400 | [diff] [blame] | 53 | AHardwareBuffer_Desc bufferDesc; |
| 54 | AHardwareBuffer_describe(graphicBuffer, &bufferDesc); |
Greg Daniel | 173464d | 2019-02-06 15:30:34 -0500 | [diff] [blame] | 55 | |
| 56 | SkColorType colorType = |
| 57 | GrAHardwareBufferUtils::GetSkColorTypeFromBufferFormat(bufferDesc.format); |
Stan Iliev | 7e910df | 2017-06-02 10:29:21 -0400 | [diff] [blame] | 58 | SkImageInfo info = SkImageInfo::Make(bufferDesc.width, bufferDesc.height, colorType, |
| 59 | alphaType, std::move(colorSpace)); |
Greg Daniel | 173464d | 2019-02-06 15:30:34 -0500 | [diff] [blame] | 60 | |
Stan Iliev | c01b5c7 | 2018-08-28 10:18:19 -0400 | [diff] [blame] | 61 | bool createProtectedImage = 0 != (bufferDesc.usage & AHARDWAREBUFFER_USAGE_PROTECTED_CONTENT); |
Stan Iliev | 505dd57 | 2018-09-13 14:20:03 -0400 | [diff] [blame] | 62 | return std::unique_ptr<SkImageGenerator>(new GrAHardwareBufferImageGenerator( |
| 63 | info, graphicBuffer, alphaType, createProtectedImage, |
| 64 | bufferDesc.format, surfaceOrigin)); |
Stan Iliev | 7e910df | 2017-06-02 10:29:21 -0400 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | GrAHardwareBufferImageGenerator::GrAHardwareBufferImageGenerator(const SkImageInfo& info, |
Stan Iliev | 114b091 | 2018-08-31 14:02:55 -0400 | [diff] [blame] | 68 | AHardwareBuffer* hardwareBuffer, SkAlphaType alphaType, bool isProtectedContent, |
Stan Iliev | 505dd57 | 2018-09-13 14:20:03 -0400 | [diff] [blame] | 69 | uint32_t bufferFormat, GrSurfaceOrigin surfaceOrigin) |
Stan Iliev | 7e910df | 2017-06-02 10:29:21 -0400 | [diff] [blame] | 70 | : INHERITED(info) |
Stan Iliev | c01b5c7 | 2018-08-28 10:18:19 -0400 | [diff] [blame] | 71 | , fHardwareBuffer(hardwareBuffer) |
Stan Iliev | 114b091 | 2018-08-31 14:02:55 -0400 | [diff] [blame] | 72 | , fBufferFormat(bufferFormat) |
Stan Iliev | 505dd57 | 2018-09-13 14:20:03 -0400 | [diff] [blame] | 73 | , fIsProtectedContent(isProtectedContent) |
| 74 | , fSurfaceOrigin(surfaceOrigin) { |
Greg Daniel | f125111 | 2018-08-27 09:55:03 -0400 | [diff] [blame] | 75 | AHardwareBuffer_acquire(fHardwareBuffer); |
| 76 | } |
| 77 | |
Stan Iliev | 7e910df | 2017-06-02 10:29:21 -0400 | [diff] [blame] | 78 | GrAHardwareBufferImageGenerator::~GrAHardwareBufferImageGenerator() { |
Greg Daniel | f125111 | 2018-08-27 09:55:03 -0400 | [diff] [blame] | 79 | AHardwareBuffer_release(fHardwareBuffer); |
Stan Iliev | 7e910df | 2017-06-02 10:29:21 -0400 | [diff] [blame] | 80 | } |
| 81 | |
Stan Iliev | 7e910df | 2017-06-02 10:29:21 -0400 | [diff] [blame] | 82 | /////////////////////////////////////////////////////////////////////////////////////////////////// |
| 83 | |
Greg Daniel | 40903af | 2020-01-30 14:55:05 -0500 | [diff] [blame] | 84 | GrSurfaceProxyView GrAHardwareBufferImageGenerator::makeView(GrRecordingContext* context) { |
Robert Phillips | 9338c60 | 2019-02-19 12:52:29 -0500 | [diff] [blame] | 85 | if (context->priv().abandoned()) { |
Greg Daniel | 40903af | 2020-01-30 14:55:05 -0500 | [diff] [blame] | 86 | return {}; |
Stan Iliev | 7e910df | 2017-06-02 10:29:21 -0400 | [diff] [blame] | 87 | } |
| 88 | |
Robert Phillips | 9338c60 | 2019-02-19 12:52:29 -0500 | [diff] [blame] | 89 | auto direct = context->priv().asDirectContext(); |
| 90 | if (!direct) { |
Greg Daniel | 40903af | 2020-01-30 14:55:05 -0500 | [diff] [blame] | 91 | return {}; |
Robert Phillips | 9338c60 | 2019-02-19 12:52:29 -0500 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | GrBackendFormat backendFormat = GrAHardwareBufferUtils::GetBackendFormat(direct, |
Greg Daniel | 173464d | 2019-02-06 15:30:34 -0500 | [diff] [blame] | 95 | fHardwareBuffer, |
| 96 | fBufferFormat, |
| 97 | false); |
| 98 | |
Robert Phillips | c80b0e9 | 2019-07-23 10:27:09 -0400 | [diff] [blame] | 99 | GrColorType grColorType = SkColorTypeToGrColorType(this->getInfo().colorType()); |
Stan Iliev | 7e910df | 2017-06-02 10:29:21 -0400 | [diff] [blame] | 100 | |
Greg Daniel | f125111 | 2018-08-27 09:55:03 -0400 | [diff] [blame] | 101 | int width = this->getInfo().width(); |
| 102 | int height = this->getInfo().height(); |
Greg Daniel | 9af948d | 2018-08-27 09:53:51 -0400 | [diff] [blame] | 103 | |
Greg Daniel | f125111 | 2018-08-27 09:55:03 -0400 | [diff] [blame] | 104 | GrTextureType textureType = GrTextureType::k2D; |
Robert Phillips | 4217ea7 | 2019-01-30 13:08:28 -0500 | [diff] [blame] | 105 | if (context->backend() == GrBackendApi::kOpenGL) { |
Greg Daniel | f125111 | 2018-08-27 09:55:03 -0400 | [diff] [blame] | 106 | textureType = GrTextureType::kExternal; |
Robert Phillips | 4217ea7 | 2019-01-30 13:08:28 -0500 | [diff] [blame] | 107 | } else if (context->backend() == GrBackendApi::kVulkan) { |
Brian Salomon | d4764a1 | 2019-08-08 12:08:24 -0400 | [diff] [blame] | 108 | VkFormat format; |
| 109 | SkAssertResult(backendFormat.asVkFormat(&format)); |
| 110 | if (format == VK_FORMAT_UNDEFINED) { |
Greg Daniel | 14c55c2 | 2018-12-04 11:25:03 -0500 | [diff] [blame] | 111 | textureType = GrTextureType::kExternal; |
| 112 | } |
Stan Iliev | 7e910df | 2017-06-02 10:29:21 -0400 | [diff] [blame] | 113 | } |
Greg Daniel | 6a0176b | 2018-01-30 09:28:44 -0500 | [diff] [blame] | 114 | |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 115 | auto proxyProvider = context->priv().proxyProvider(); |
Greg Daniel | f125111 | 2018-08-27 09:55:03 -0400 | [diff] [blame] | 116 | |
| 117 | AHardwareBuffer* hardwareBuffer = fHardwareBuffer; |
| 118 | AHardwareBuffer_acquire(hardwareBuffer); |
| 119 | |
Stan Iliev | c01b5c7 | 2018-08-28 10:18:19 -0400 | [diff] [blame] | 120 | const bool isProtectedContent = fIsProtectedContent; |
Greg Daniel | f125111 | 2018-08-27 09:55:03 -0400 | [diff] [blame] | 121 | |
Brian Salomon | 67f0195 | 2019-02-14 13:05:25 -0500 | [diff] [blame] | 122 | class AutoAHBRelease { |
| 123 | public: |
| 124 | AutoAHBRelease(AHardwareBuffer* ahb) : fAhb(ahb) {} |
| 125 | // std::function() must be CopyConstructible, but ours should never actually be copied. |
| 126 | AutoAHBRelease(const AutoAHBRelease&) { SkASSERT(0); } |
| 127 | AutoAHBRelease(AutoAHBRelease&& that) : fAhb(that.fAhb) { that.fAhb = nullptr; } |
| 128 | ~AutoAHBRelease() { fAhb ? AHardwareBuffer_release(fAhb) : void(); } |
Greg Daniel | f125111 | 2018-08-27 09:55:03 -0400 | [diff] [blame] | 129 | |
Brian Salomon | 67f0195 | 2019-02-14 13:05:25 -0500 | [diff] [blame] | 130 | AutoAHBRelease& operator=(AutoAHBRelease&& that) { |
| 131 | fAhb = skstd::exchange(that.fAhb, nullptr); |
| 132 | return *this; |
| 133 | } |
| 134 | AutoAHBRelease& operator=(const AutoAHBRelease&) = delete; |
| 135 | |
| 136 | AHardwareBuffer* get() const { return fAhb; } |
| 137 | |
| 138 | private: |
| 139 | AHardwareBuffer* fAhb; |
| 140 | }; |
| 141 | |
| 142 | sk_sp<GrTextureProxy> texProxy = proxyProvider->createLazyProxy( |
Brian Salomon | beb7f52 | 2019-08-30 16:19:42 -0400 | [diff] [blame] | 143 | [direct, buffer = AutoAHBRelease(hardwareBuffer), width, height, isProtectedContent, |
Brian Salomon | 8a78e9c | 2020-03-27 10:42:15 -0400 | [diff] [blame^] | 144 | backendFormat]( |
Brian Salomon | beb7f52 | 2019-08-30 16:19:42 -0400 | [diff] [blame] | 145 | GrResourceProvider* resourceProvider) -> GrSurfaceProxy::LazyCallbackResult { |
Greg Daniel | 173464d | 2019-02-06 15:30:34 -0500 | [diff] [blame] | 146 | GrAHardwareBufferUtils::DeleteImageProc deleteImageProc = nullptr; |
Stan Iliev | a56b04a | 2019-08-01 14:22:34 -0400 | [diff] [blame] | 147 | GrAHardwareBufferUtils::UpdateImageProc updateImageProc = nullptr; |
| 148 | GrAHardwareBufferUtils::TexImageCtx texImageCtx = nullptr; |
Greg Daniel | f125111 | 2018-08-27 09:55:03 -0400 | [diff] [blame] | 149 | |
Greg Daniel | 173464d | 2019-02-06 15:30:34 -0500 | [diff] [blame] | 150 | GrBackendTexture backendTex = |
Robert Phillips | 9338c60 | 2019-02-19 12:52:29 -0500 | [diff] [blame] | 151 | GrAHardwareBufferUtils::MakeBackendTexture(direct, buffer.get(), |
Greg Daniel | 173464d | 2019-02-06 15:30:34 -0500 | [diff] [blame] | 152 | width, height, |
Greg Daniel | f125111 | 2018-08-27 09:55:03 -0400 | [diff] [blame] | 153 | &deleteImageProc, |
Stan Iliev | a56b04a | 2019-08-01 14:22:34 -0400 | [diff] [blame] | 154 | &updateImageProc, |
| 155 | &texImageCtx, |
Stan Iliev | 114b091 | 2018-08-31 14:02:55 -0400 | [diff] [blame] | 156 | isProtectedContent, |
Greg Daniel | 173464d | 2019-02-06 15:30:34 -0500 | [diff] [blame] | 157 | backendFormat, |
| 158 | false); |
Greg Daniel | f125111 | 2018-08-27 09:55:03 -0400 | [diff] [blame] | 159 | if (!backendTex.isValid()) { |
Brian Salomon | b6a3a3b | 2019-04-01 12:29:34 -0400 | [diff] [blame] | 160 | return {}; |
Greg Daniel | f125111 | 2018-08-27 09:55:03 -0400 | [diff] [blame] | 161 | } |
Stan Iliev | a56b04a | 2019-08-01 14:22:34 -0400 | [diff] [blame] | 162 | SkASSERT(deleteImageProc && texImageCtx); |
Greg Daniel | f125111 | 2018-08-27 09:55:03 -0400 | [diff] [blame] | 163 | |
Brian Salomon | aa6ca0a | 2019-01-24 16:03:07 -0500 | [diff] [blame] | 164 | // We make this texture cacheable to avoid recreating a GrTexture every time this |
| 165 | // is invoked. We know the owning SkIamge will send an invalidation message when the |
| 166 | // image is destroyed, so the texture will be removed at that time. |
Brian Salomon | c67c31c | 2018-12-06 10:00:03 -0500 | [diff] [blame] | 167 | sk_sp<GrTexture> tex = resourceProvider->wrapBackendTexture( |
Brian Salomon | 8a78e9c | 2020-03-27 10:42:15 -0400 | [diff] [blame^] | 168 | backendTex, kBorrow_GrWrapOwnership, GrWrapCacheable::kYes, kRead_GrIOType); |
Greg Daniel | f125111 | 2018-08-27 09:55:03 -0400 | [diff] [blame] | 169 | if (!tex) { |
Stan Iliev | a56b04a | 2019-08-01 14:22:34 -0400 | [diff] [blame] | 170 | deleteImageProc(texImageCtx); |
Brian Salomon | b6a3a3b | 2019-04-01 12:29:34 -0400 | [diff] [blame] | 171 | return {}; |
Greg Daniel | f125111 | 2018-08-27 09:55:03 -0400 | [diff] [blame] | 172 | } |
| 173 | |
Greg Daniel | 637c06a | 2018-09-12 09:44:25 -0400 | [diff] [blame] | 174 | if (deleteImageProc) { |
Stan Iliev | a56b04a | 2019-08-01 14:22:34 -0400 | [diff] [blame] | 175 | tex->setRelease(deleteImageProc, texImageCtx); |
Greg Daniel | 637c06a | 2018-09-12 09:44:25 -0400 | [diff] [blame] | 176 | } |
Stan Iliev | 7e910df | 2017-06-02 10:29:21 -0400 | [diff] [blame] | 177 | |
Brian Salomon | 9c73e3d | 2019-08-15 10:55:49 -0400 | [diff] [blame] | 178 | return tex; |
Greg Daniel | f125111 | 2018-08-27 09:55:03 -0400 | [diff] [blame] | 179 | }, |
Brian Salomon | df1bd6d | 2020-03-26 20:37:01 -0400 | [diff] [blame] | 180 | backendFormat, {width, height}, GrRenderable::kNo, 1, GrMipMapped::kNo, |
Greg Daniel | 3a36511 | 2020-02-14 10:47:18 -0500 | [diff] [blame] | 181 | GrMipMapsStatus::kNotAllocated, GrInternalSurfaceFlags::kReadOnly, SkBackingFit::kExact, |
| 182 | SkBudgeted::kNo, GrProtected::kNo, GrSurfaceProxy::UseAllocator::kYes); |
Greg Daniel | f125111 | 2018-08-27 09:55:03 -0400 | [diff] [blame] | 183 | |
Brian Salomon | df1bd6d | 2020-03-26 20:37:01 -0400 | [diff] [blame] | 184 | GrSwizzle readSwizzle = context->priv().caps()->getReadSwizzle(backendFormat, grColorType); |
| 185 | |
Greg Daniel | 40903af | 2020-01-30 14:55:05 -0500 | [diff] [blame] | 186 | return GrSurfaceProxyView(std::move(texProxy), fSurfaceOrigin, readSwizzle); |
Greg Daniel | 3860cfd1 | 2018-09-07 09:13:54 -0400 | [diff] [blame] | 187 | } |
| 188 | |
Brian Salomon | bc074a6 | 2020-03-18 10:06:13 -0400 | [diff] [blame] | 189 | GrSurfaceProxyView GrAHardwareBufferImageGenerator::onGenerateTexture( |
| 190 | GrRecordingContext* context, |
| 191 | const SkImageInfo& info, |
| 192 | const SkIPoint& origin, |
| 193 | GrMipMapped mipMapped, |
| 194 | GrImageTexGenPolicy texGenPolicy) { |
Greg Daniel | 40903af | 2020-01-30 14:55:05 -0500 | [diff] [blame] | 195 | GrSurfaceProxyView texProxyView = this->makeView(context); |
| 196 | if (!texProxyView.proxy()) { |
Greg Daniel | cc104db | 2020-02-03 14:17:08 -0500 | [diff] [blame] | 197 | return {}; |
Greg Daniel | 3860cfd1 | 2018-09-07 09:13:54 -0400 | [diff] [blame] | 198 | } |
Greg Daniel | cc104db | 2020-02-03 14:17:08 -0500 | [diff] [blame] | 199 | SkASSERT(texProxyView.asTextureProxy()); |
Greg Daniel | 3860cfd1 | 2018-09-07 09:13:54 -0400 | [diff] [blame] | 200 | |
Brian Salomon | bc074a6 | 2020-03-18 10:06:13 -0400 | [diff] [blame] | 201 | if (texGenPolicy == GrImageTexGenPolicy::kDraw && origin.isZero() && |
| 202 | info.dimensions() == this->getInfo().dimensions() && mipMapped == GrMipMapped::kNo) { |
Brian Salomon | a54af92 | 2020-03-03 16:56:22 -0500 | [diff] [blame] | 203 | // If the caller wants the full non-MIP mapped texture we're done. |
Greg Daniel | cc104db | 2020-02-03 14:17:08 -0500 | [diff] [blame] | 204 | return texProxyView; |
Greg Daniel | 3860cfd1 | 2018-09-07 09:13:54 -0400 | [diff] [blame] | 205 | } |
Brian Salomon | a54af92 | 2020-03-03 16:56:22 -0500 | [diff] [blame] | 206 | // Otherwise, make a copy for the requested subset and/or MIP maps. |
Greg Daniel | 3860cfd1 | 2018-09-07 09:13:54 -0400 | [diff] [blame] | 207 | SkIRect subset = SkIRect::MakeXYWH(origin.fX, origin.fY, info.width(), info.height()); |
| 208 | |
Brian Salomon | bc074a6 | 2020-03-18 10:06:13 -0400 | [diff] [blame] | 209 | SkBudgeted budgeted = texGenPolicy == GrImageTexGenPolicy::kNew_Uncached_Unbudgeted |
| 210 | ? SkBudgeted::kNo |
| 211 | : SkBudgeted::kYes; |
| 212 | |
Greg Daniel | 3155f7f | 2020-01-16 16:54:26 -0500 | [diff] [blame] | 213 | GrColorType grColorType = SkColorTypeToGrColorType(this->getInfo().colorType()); |
Greg Daniel | 40903af | 2020-01-30 14:55:05 -0500 | [diff] [blame] | 214 | return GrSurfaceProxy::Copy(context, texProxyView.proxy(), texProxyView.origin(), grColorType, |
Brian Salomon | bc074a6 | 2020-03-18 10:06:13 -0400 | [diff] [blame] | 215 | mipMapped, subset, SkBackingFit::kExact, budgeted); |
Stan Iliev | 7e910df | 2017-06-02 10:29:21 -0400 | [diff] [blame] | 216 | } |
Stan Iliev | 7e910df | 2017-06-02 10:29:21 -0400 | [diff] [blame] | 217 | |
| 218 | bool GrAHardwareBufferImageGenerator::onIsValid(GrContext* context) const { |
| 219 | if (nullptr == context) { |
| 220 | return false; //CPU backend is not supported, because hardware buffer can be swizzled |
| 221 | } |
Robert Phillips | 4217ea7 | 2019-01-30 13:08:28 -0500 | [diff] [blame] | 222 | return GrBackendApi::kOpenGL == context->backend() || |
| 223 | GrBackendApi::kVulkan == context->backend(); |
Stan Iliev | 7e910df | 2017-06-02 10:29:21 -0400 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | #endif //SK_BUILD_FOR_ANDROID_FRAMEWORK |