Stan Iliev | 500a0c3 | 2016-10-26 10:30:09 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include "SkiaOpenGLPipeline.h" |
| 18 | |
Kevin Lubick | 6817fc4 | 2023-05-12 19:27:20 +0000 | [diff] [blame] | 19 | #include <include/gpu/ganesh/SkSurfaceGanesh.h> |
Kevin Lubick | 867a79c | 2023-08-14 14:19:11 +0000 | [diff] [blame^] | 20 | #include <include/gpu/gl/GrGLTypes.h> |
Alec Mouri | 3afb397 | 2022-05-27 22:03:11 +0000 | [diff] [blame] | 21 | #include <GrBackendSurface.h> |
| 22 | #include <SkBlendMode.h> |
| 23 | #include <SkImageInfo.h> |
| 24 | #include <cutils/properties.h> |
rnlee | ce9762b | 2021-05-21 15:40:53 -0700 | [diff] [blame] | 25 | #include <gui/TraceUtils.h> |
Alec Mouri | 3afb397 | 2022-05-27 22:03:11 +0000 | [diff] [blame] | 26 | #include <strings.h> |
| 27 | |
Stan Iliev | 500a0c3 | 2016-10-26 10:30:09 -0400 | [diff] [blame] | 28 | #include "DeferredLayerUpdater.h" |
Alec Mouri | 3afb397 | 2022-05-27 22:03:11 +0000 | [diff] [blame] | 29 | #include "FrameInfo.h" |
Derek Sollenberger | c4fbada | 2016-11-07 16:05:41 -0500 | [diff] [blame] | 30 | #include "LayerDrawable.h" |
Fedor Kudasov | 90df056 | 2019-06-19 11:41:34 +0100 | [diff] [blame] | 31 | #include "LightingInfo.h" |
Matt Sarett | cf2c05c | 2016-10-26 11:03:23 -0400 | [diff] [blame] | 32 | #include "SkiaPipeline.h" |
| 33 | #include "SkiaProfileRenderer.h" |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 34 | #include "hwui/Bitmap.h" |
Derek Sollenberger | 28a4d99 | 2018-09-20 13:37:24 -0400 | [diff] [blame] | 35 | #include "private/hwui/DrawGlInfo.h" |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 36 | #include "renderstate/RenderState.h" |
| 37 | #include "renderthread/EglManager.h" |
| 38 | #include "renderthread/Frame.h" |
Alec Mouri | 3afb397 | 2022-05-27 22:03:11 +0000 | [diff] [blame] | 39 | #include "renderthread/IRenderPipeline.h" |
John Reck | d9d7f12 | 2018-05-03 14:40:56 -0700 | [diff] [blame] | 40 | #include "utils/GLUtils.h" |
Stan Iliev | 500a0c3 | 2016-10-26 10:30:09 -0400 | [diff] [blame] | 41 | |
Stan Iliev | 500a0c3 | 2016-10-26 10:30:09 -0400 | [diff] [blame] | 42 | using namespace android::uirenderer::renderthread; |
| 43 | |
| 44 | namespace android { |
| 45 | namespace uirenderer { |
| 46 | namespace skiapipeline { |
| 47 | |
| 48 | SkiaOpenGLPipeline::SkiaOpenGLPipeline(RenderThread& thread) |
Derek Sollenberger | 5a5a648 | 2018-09-19 13:52:13 -0400 | [diff] [blame] | 49 | : SkiaPipeline(thread), mEglManager(thread.eglManager()) { |
| 50 | thread.renderState().registerContextCallback(this); |
| 51 | } |
| 52 | |
| 53 | SkiaOpenGLPipeline::~SkiaOpenGLPipeline() { |
| 54 | mRenderThread.renderState().removeContextCallback(this); |
| 55 | } |
Stan Iliev | 500a0c3 | 2016-10-26 10:30:09 -0400 | [diff] [blame] | 56 | |
| 57 | MakeCurrentResult SkiaOpenGLPipeline::makeCurrent() { |
Shih-Hsin Li | 4a012f5 | 2021-09-21 18:11:23 -0700 | [diff] [blame] | 58 | bool wasSurfaceless = mEglManager.isCurrent(EGL_NO_SURFACE); |
| 59 | |
Derek Sollenberger | b830772 | 2022-08-30 14:24:22 -0400 | [diff] [blame] | 60 | // In case the surface was destroyed (e.g. a previous trimMemory call) we |
| 61 | // need to recreate it here. |
Nader Jawad | a352185 | 2023-01-30 20:23:46 -0800 | [diff] [blame] | 62 | if (mHardwareBuffer) { |
| 63 | mRenderThread.requireGlContext(); |
| 64 | } else if (!isSurfaceReady() && mNativeWindow) { |
Derek Sollenberger | b830772 | 2022-08-30 14:24:22 -0400 | [diff] [blame] | 65 | setSurface(mNativeWindow.get(), mSwapBehavior); |
| 66 | } |
| 67 | |
Stan Iliev | 500a0c3 | 2016-10-26 10:30:09 -0400 | [diff] [blame] | 68 | EGLint error = 0; |
| 69 | if (!mEglManager.makeCurrent(mEglSurface, &error)) { |
| 70 | return MakeCurrentResult::AlreadyCurrent; |
| 71 | } |
Shih-Hsin Li | 4a012f5 | 2021-09-21 18:11:23 -0700 | [diff] [blame] | 72 | |
Shih-hsin Li | d82c91d | 2023-04-21 12:13:47 -0700 | [diff] [blame] | 73 | EGLint majorVersion = 0; |
| 74 | eglQueryContext(eglGetCurrentDisplay(), eglGetCurrentContext(), EGL_CONTEXT_CLIENT_VERSION, &majorVersion); |
| 75 | |
| 76 | // Make sure read/draw buffer state of default framebuffer is GL_BACK for ES 3.X. Vendor implementations |
Shih-Hsin Li | 4a012f5 | 2021-09-21 18:11:23 -0700 | [diff] [blame] | 77 | // disagree on the draw/read buffer state if the default framebuffer transitions from a surface |
| 78 | // to EGL_NO_SURFACE and vice-versa. There was a related discussion within Khronos on this topic. |
| 79 | // See https://cvs.khronos.org/bugzilla/show_bug.cgi?id=13534. |
| 80 | // The discussion was not resolved with a clear consensus |
Shih-hsin Li | d82c91d | 2023-04-21 12:13:47 -0700 | [diff] [blame] | 81 | if (error == 0 && (majorVersion > 2) && wasSurfaceless && mEglSurface != EGL_NO_SURFACE) { |
Shih-Hsin Li | 4a012f5 | 2021-09-21 18:11:23 -0700 | [diff] [blame] | 82 | GLint curReadFB = 0; |
| 83 | GLint curDrawFB = 0; |
| 84 | glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &curReadFB); |
| 85 | glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &curDrawFB); |
| 86 | |
| 87 | GLint buffer = GL_NONE; |
| 88 | glBindFramebuffer(GL_FRAMEBUFFER, 0); |
| 89 | glGetIntegerv(GL_DRAW_BUFFER0, &buffer); |
| 90 | if (buffer == GL_NONE) { |
| 91 | const GLenum drawBuffer = GL_BACK; |
| 92 | glDrawBuffers(1, &drawBuffer); |
| 93 | } |
| 94 | |
| 95 | glGetIntegerv(GL_READ_BUFFER, &buffer); |
| 96 | if (buffer == GL_NONE) { |
| 97 | glReadBuffer(GL_BACK); |
| 98 | } |
| 99 | |
| 100 | glBindFramebuffer(GL_READ_FRAMEBUFFER, curReadFB); |
| 101 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER, curDrawFB); |
| 102 | |
| 103 | GL_CHECKPOINT(LOW); |
| 104 | } |
| 105 | |
Stan Iliev | 500a0c3 | 2016-10-26 10:30:09 -0400 | [diff] [blame] | 106 | return error ? MakeCurrentResult::Failed : MakeCurrentResult::Succeeded; |
| 107 | } |
| 108 | |
| 109 | Frame SkiaOpenGLPipeline::getFrame() { |
Nader Jawad | 2461722 | 2023-03-30 12:29:01 -0700 | [diff] [blame] | 110 | LOG_ALWAYS_FATAL_IF(mEglSurface == EGL_NO_SURFACE, |
| 111 | "drawRenderNode called on a context with no surface!"); |
| 112 | return mEglManager.beginFrame(mEglSurface); |
Stan Iliev | 500a0c3 | 2016-10-26 10:30:09 -0400 | [diff] [blame] | 113 | } |
| 114 | |
Alec Mouri | 3afb397 | 2022-05-27 22:03:11 +0000 | [diff] [blame] | 115 | IRenderPipeline::DrawResult SkiaOpenGLPipeline::draw( |
| 116 | const Frame& frame, const SkRect& screenDirty, const SkRect& dirty, |
| 117 | const LightGeometry& lightGeometry, LayerUpdateQueue* layerUpdateQueue, |
| 118 | const Rect& contentDrawBounds, bool opaque, const LightInfo& lightInfo, |
Nader Jawad | a352185 | 2023-01-30 20:23:46 -0800 | [diff] [blame] | 119 | const std::vector<sp<RenderNode>>& renderNodes, FrameInfoVisualizer* profiler, |
| 120 | const HardwareBufferRenderParams& bufferParams) { |
| 121 | if (!isCapturingSkp() && !mHardwareBuffer) { |
John Reck | 7600518 | 2021-06-09 22:43:05 -0400 | [diff] [blame] | 122 | mEglManager.damageFrame(frame, dirty); |
| 123 | } |
Stan Iliev | 500a0c3 | 2016-10-26 10:30:09 -0400 | [diff] [blame] | 124 | |
Peiyong Lin | 1f6aa12 | 2018-09-10 16:28:08 -0700 | [diff] [blame] | 125 | SkColorType colorType = getSurfaceColorType(); |
Stan Iliev | 500a0c3 | 2016-10-26 10:30:09 -0400 | [diff] [blame] | 126 | // setup surface for fbo0 |
Greg Daniel | ac2d232 | 2017-07-12 11:30:15 -0400 | [diff] [blame] | 127 | GrGLFramebufferInfo fboInfo; |
| 128 | fboInfo.fFBOID = 0; |
Peiyong Lin | 1f6aa12 | 2018-09-10 16:28:08 -0700 | [diff] [blame] | 129 | if (colorType == kRGBA_F16_SkColorType) { |
Greg Daniel | c9da8e8 | 2018-03-21 10:50:24 -0400 | [diff] [blame] | 130 | fboInfo.fFormat = GL_RGBA16F; |
Peiyong Lin | 1f6aa12 | 2018-09-10 16:28:08 -0700 | [diff] [blame] | 131 | } else if (colorType == kN32_SkColorType) { |
| 132 | // Note: The default preference of pixel format is RGBA_8888, when other |
| 133 | // pixel format is available, we should branch out and do more check. |
Greg Daniel | c9da8e8 | 2018-03-21 10:50:24 -0400 | [diff] [blame] | 134 | fboInfo.fFormat = GL_RGBA8; |
John Reck | b36bfdd | 2020-07-23 13:47:49 -0700 | [diff] [blame] | 135 | } else if (colorType == kRGBA_1010102_SkColorType) { |
| 136 | fboInfo.fFormat = GL_RGB10_A2; |
Leon Scroggins III | e157ee8 | 2021-11-30 14:12:42 -0500 | [diff] [blame] | 137 | } else if (colorType == kAlpha_8_SkColorType) { |
| 138 | fboInfo.fFormat = GL_R8; |
Peiyong Lin | 1f6aa12 | 2018-09-10 16:28:08 -0700 | [diff] [blame] | 139 | } else { |
| 140 | LOG_ALWAYS_FATAL("Unsupported color type."); |
Greg Daniel | c9da8e8 | 2018-03-21 10:50:24 -0400 | [diff] [blame] | 141 | } |
Greg Daniel | ac2d232 | 2017-07-12 11:30:15 -0400 | [diff] [blame] | 142 | |
Greg Daniel | c9da8e8 | 2018-03-21 10:50:24 -0400 | [diff] [blame] | 143 | GrBackendRenderTarget backendRT(frame.width(), frame.height(), 0, STENCIL_BUFFER_SIZE, fboInfo); |
Stan Iliev | 500a0c3 | 2016-10-26 10:30:09 -0400 | [diff] [blame] | 144 | |
John Reck | b026f35 | 2023-04-05 13:19:15 -0400 | [diff] [blame] | 145 | SkSurfaceProps props(mColorMode == ColorMode::Default ? 0 : SkSurfaceProps::kAlwaysDither_Flag, |
| 146 | kUnknown_SkPixelGeometry); |
Stan Iliev | 500a0c3 | 2016-10-26 10:30:09 -0400 | [diff] [blame] | 147 | |
| 148 | SkASSERT(mRenderThread.getGrContext() != nullptr); |
Nader Jawad | a352185 | 2023-01-30 20:23:46 -0800 | [diff] [blame] | 149 | sk_sp<SkSurface> surface; |
| 150 | SkMatrix preTransform; |
| 151 | if (mHardwareBuffer) { |
| 152 | surface = getBufferSkSurface(bufferParams); |
| 153 | preTransform = bufferParams.getTransform(); |
| 154 | } else { |
Kevin Lubick | 6817fc4 | 2023-05-12 19:27:20 +0000 | [diff] [blame] | 155 | surface = SkSurfaces::WrapBackendRenderTarget(mRenderThread.getGrContext(), backendRT, |
| 156 | getSurfaceOrigin(), colorType, |
| 157 | mSurfaceColorSpace, &props); |
Nader Jawad | a352185 | 2023-01-30 20:23:46 -0800 | [diff] [blame] | 158 | preTransform = SkMatrix::I(); |
| 159 | } |
Stan Iliev | 500a0c3 | 2016-10-26 10:30:09 -0400 | [diff] [blame] | 160 | |
Nader Jawad | a352185 | 2023-01-30 20:23:46 -0800 | [diff] [blame] | 161 | SkPoint lightCenter = preTransform.mapXY(lightGeometry.center.x, lightGeometry.center.y); |
| 162 | LightGeometry localGeometry = lightGeometry; |
| 163 | localGeometry.center.x = lightCenter.fX; |
| 164 | localGeometry.center.y = lightCenter.fY; |
| 165 | LightingInfo::updateLighting(localGeometry, lightInfo); |
Greg Daniel | c407678 | 2019-01-08 16:01:18 -0500 | [diff] [blame] | 166 | renderFrame(*layerUpdateQueue, dirty, renderNodes, opaque, contentDrawBounds, surface, |
Nader Jawad | a352185 | 2023-01-30 20:23:46 -0800 | [diff] [blame] | 167 | preTransform); |
Matt Sarett | cf2c05c | 2016-10-26 11:03:23 -0400 | [diff] [blame] | 168 | |
| 169 | // Draw visual debugging features |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 170 | if (CC_UNLIKELY(Properties::showDirtyRegions || |
| 171 | ProfileType::None != Properties::getProfileType())) { |
Matt Sarett | cf2c05c | 2016-10-26 11:03:23 -0400 | [diff] [blame] | 172 | SkCanvas* profileCanvas = surface->getCanvas(); |
John Reck | c30836d | 2022-08-12 14:28:31 -0400 | [diff] [blame] | 173 | SkiaProfileRenderer profileRenderer(profileCanvas, frame.width(), frame.height()); |
Matt Sarett | cf2c05c | 2016-10-26 11:03:23 -0400 | [diff] [blame] | 174 | profiler->draw(profileRenderer); |
Matt Sarett | cf2c05c | 2016-10-26 11:03:23 -0400 | [diff] [blame] | 175 | } |
| 176 | |
Greg Daniel | be2803a | 2021-02-19 18:32:16 -0500 | [diff] [blame] | 177 | { |
| 178 | ATRACE_NAME("flush commands"); |
Kevin Lubick | aa592d0 | 2023-05-30 15:07:06 +0000 | [diff] [blame] | 179 | skgpu::ganesh::FlushAndSubmit(surface); |
Greg Daniel | be2803a | 2021-02-19 18:32:16 -0500 | [diff] [blame] | 180 | } |
| 181 | layerUpdateQueue->clear(); |
| 182 | |
Matt Sarett | 4bda6bf | 2016-11-07 15:43:41 -0500 | [diff] [blame] | 183 | // Log memory statistics |
| 184 | if (CC_UNLIKELY(Properties::debugLevel != kDebugDisabled)) { |
| 185 | dumpResourceCacheUsage(); |
| 186 | } |
| 187 | |
Alec Mouri | 3afb397 | 2022-05-27 22:03:11 +0000 | [diff] [blame] | 188 | return {true, IRenderPipeline::DrawResult::kUnknownTime}; |
Stan Iliev | 500a0c3 | 2016-10-26 10:30:09 -0400 | [diff] [blame] | 189 | } |
| 190 | |
John Reck | 1bcacfd | 2017-11-03 10:12:19 -0700 | [diff] [blame] | 191 | bool SkiaOpenGLPipeline::swapBuffers(const Frame& frame, bool drew, const SkRect& screenDirty, |
| 192 | FrameInfo* currentFrameInfo, bool* requireSwap) { |
Stan Iliev | 500a0c3 | 2016-10-26 10:30:09 -0400 | [diff] [blame] | 193 | GL_CHECKPOINT(LOW); |
| 194 | |
| 195 | // Even if we decided to cancel the frame, from the perspective of jank |
| 196 | // metrics the frame was swapped at this point |
| 197 | currentFrameInfo->markSwapBuffers(); |
| 198 | |
Nader Jawad | a352185 | 2023-01-30 20:23:46 -0800 | [diff] [blame] | 199 | if (mHardwareBuffer) { |
| 200 | return false; |
| 201 | } |
| 202 | |
Stan Iliev | 500a0c3 | 2016-10-26 10:30:09 -0400 | [diff] [blame] | 203 | *requireSwap = drew || mEglManager.damageRequiresSwap(); |
| 204 | |
| 205 | if (*requireSwap && (CC_UNLIKELY(!mEglManager.swapBuffers(frame, screenDirty)))) { |
| 206 | return false; |
| 207 | } |
| 208 | |
| 209 | return *requireSwap; |
| 210 | } |
| 211 | |
Stan Iliev | 500a0c3 | 2016-10-26 10:30:09 -0400 | [diff] [blame] | 212 | DeferredLayerUpdater* SkiaOpenGLPipeline::createTextureLayer() { |
John Reck | 1e51071 | 2018-04-23 08:15:03 -0700 | [diff] [blame] | 213 | mRenderThread.requireGlContext(); |
Stan Iliev | 564ca3e | 2018-09-04 22:00:00 +0000 | [diff] [blame] | 214 | return new DeferredLayerUpdater(mRenderThread.renderState()); |
Stan Iliev | 500a0c3 | 2016-10-26 10:30:09 -0400 | [diff] [blame] | 215 | } |
| 216 | |
Derek Sollenberger | 5a5a648 | 2018-09-19 13:52:13 -0400 | [diff] [blame] | 217 | void SkiaOpenGLPipeline::onContextDestroyed() { |
| 218 | if (mEglSurface != EGL_NO_SURFACE) { |
| 219 | mEglManager.destroySurface(mEglSurface); |
| 220 | mEglSurface = EGL_NO_SURFACE; |
| 221 | } |
| 222 | } |
| 223 | |
Stan Iliev | 500a0c3 | 2016-10-26 10:30:09 -0400 | [diff] [blame] | 224 | void SkiaOpenGLPipeline::onStop() { |
| 225 | if (mEglManager.isCurrent(mEglSurface)) { |
| 226 | mEglManager.makeCurrent(EGL_NO_SURFACE); |
| 227 | } |
| 228 | } |
| 229 | |
John Reck | 8ddbc59 | 2020-05-07 16:11:18 -0700 | [diff] [blame] | 230 | bool SkiaOpenGLPipeline::setSurface(ANativeWindow* surface, SwapBehavior swapBehavior) { |
Derek Sollenberger | b830772 | 2022-08-30 14:24:22 -0400 | [diff] [blame] | 231 | mNativeWindow = surface; |
| 232 | mSwapBehavior = swapBehavior; |
| 233 | |
Stan Iliev | 500a0c3 | 2016-10-26 10:30:09 -0400 | [diff] [blame] | 234 | if (mEglSurface != EGL_NO_SURFACE) { |
| 235 | mEglManager.destroySurface(mEglSurface); |
| 236 | mEglSurface = EGL_NO_SURFACE; |
| 237 | } |
| 238 | |
| 239 | if (surface) { |
John Reck | 1e51071 | 2018-04-23 08:15:03 -0700 | [diff] [blame] | 240 | mRenderThread.requireGlContext(); |
Derek Sollenberger | 1863d94 | 2020-02-05 15:41:51 -0500 | [diff] [blame] | 241 | auto newSurface = mEglManager.createSurface(surface, mColorMode, mSurfaceColorSpace); |
John Reck | 8e539ca | 2018-11-15 15:21:29 -0800 | [diff] [blame] | 242 | if (!newSurface) { |
| 243 | return false; |
| 244 | } |
| 245 | mEglSurface = newSurface.unwrap(); |
Stan Iliev | 500a0c3 | 2016-10-26 10:30:09 -0400 | [diff] [blame] | 246 | } |
| 247 | |
| 248 | if (mEglSurface != EGL_NO_SURFACE) { |
| 249 | const bool preserveBuffer = (swapBehavior != SwapBehavior::kSwap_discardBuffer); |
John Reck | 3c26088 | 2023-05-30 17:39:21 -0400 | [diff] [blame] | 250 | mEglManager.setPreserveBuffer(mEglSurface, preserveBuffer); |
Stan Iliev | 500a0c3 | 2016-10-26 10:30:09 -0400 | [diff] [blame] | 251 | return true; |
| 252 | } |
| 253 | |
| 254 | return false; |
| 255 | } |
| 256 | |
Nader Jawad | a352185 | 2023-01-30 20:23:46 -0800 | [diff] [blame] | 257 | [[nodiscard]] android::base::unique_fd SkiaOpenGLPipeline::flush() { |
| 258 | int fence = -1; |
| 259 | EGLSyncKHR sync = EGL_NO_SYNC_KHR; |
| 260 | mEglManager.createReleaseFence(true, &sync, &fence); |
| 261 | // If a sync object is returned here then the device does not support native |
| 262 | // fences, we block on the returned sync and return -1 as a file descriptor |
| 263 | if (sync != EGL_NO_SYNC_KHR) { |
| 264 | EGLDisplay display = mEglManager.eglDisplay(); |
| 265 | EGLint result = eglClientWaitSyncKHR(display, sync, 0, 1000000000); |
| 266 | if (result == EGL_FALSE) { |
| 267 | ALOGE("EglManager::createReleaseFence: error waiting for previous fence: %#x", |
| 268 | eglGetError()); |
| 269 | } else if (result == EGL_TIMEOUT_EXPIRED_KHR) { |
| 270 | ALOGE("EglManager::createReleaseFence: timeout waiting for previous fence"); |
| 271 | } |
| 272 | eglDestroySyncKHR(display, sync); |
| 273 | } |
| 274 | return android::base::unique_fd(fence); |
| 275 | } |
| 276 | |
Stan Iliev | 500a0c3 | 2016-10-26 10:30:09 -0400 | [diff] [blame] | 277 | bool SkiaOpenGLPipeline::isSurfaceReady() { |
| 278 | return CC_UNLIKELY(mEglSurface != EGL_NO_SURFACE); |
| 279 | } |
| 280 | |
| 281 | bool SkiaOpenGLPipeline::isContextReady() { |
| 282 | return CC_LIKELY(mEglManager.hasEglContext()); |
| 283 | } |
| 284 | |
| 285 | void SkiaOpenGLPipeline::invokeFunctor(const RenderThread& thread, Functor* functor) { |
| 286 | DrawGlInfo::Mode mode = DrawGlInfo::kModeProcessNoContext; |
| 287 | if (thread.eglManager().hasEglContext()) { |
| 288 | mode = DrawGlInfo::kModeProcess; |
| 289 | } |
| 290 | |
| 291 | (*functor)(mode, nullptr); |
| 292 | |
| 293 | // If there's no context we don't need to reset as there's no gl state to save/restore |
| 294 | if (mode != DrawGlInfo::kModeProcessNoContext) { |
| 295 | thread.getGrContext()->resetContext(); |
| 296 | } |
| 297 | } |
| 298 | |
Stan Iliev | 500a0c3 | 2016-10-26 10:30:09 -0400 | [diff] [blame] | 299 | } /* namespace skiapipeline */ |
| 300 | } /* namespace uirenderer */ |
| 301 | } /* namespace android */ |