Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2013 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 | |
Peiyong Lin | 7e219eb | 2018-12-03 05:40:42 -0800 | [diff] [blame] | 17 | #ifndef SF_GLESRENDERENGINE_H_ |
| 18 | #define SF_GLESRENDERENGINE_H_ |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 19 | |
| 20 | #include <stdint.h> |
Alec Mouri | 554d06e | 2018-12-20 00:15:33 -0800 | [diff] [blame] | 21 | #include <condition_variable> |
Alec Mouri | da4cf3b | 2019-02-12 15:33:01 -0800 | [diff] [blame] | 22 | #include <deque> |
Alec Mouri | 554d06e | 2018-12-20 00:15:33 -0800 | [diff] [blame] | 23 | #include <mutex> |
| 24 | #include <queue> |
| 25 | #include <thread> |
Alec Mouri | da4cf3b | 2019-02-12 15:33:01 -0800 | [diff] [blame] | 26 | #include <unordered_map> |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 27 | |
Peiyong Lin | f11f39b | 2018-09-05 14:37:41 -0700 | [diff] [blame] | 28 | #include <EGL/egl.h> |
| 29 | #include <EGL/eglext.h> |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 30 | #include <GLES2/gl2.h> |
Alec Mouri | 16a9940 | 2019-07-29 16:37:30 -0700 | [diff] [blame] | 31 | #include <android-base/thread_annotations.h> |
Peiyong Lin | cbc184f | 2018-08-22 13:24:10 -0700 | [diff] [blame] | 32 | #include <renderengine/RenderEngine.h> |
Peiyong Lin | 833074a | 2018-08-28 11:53:54 -0700 | [diff] [blame] | 33 | #include <renderengine/private/Description.h> |
Alec Mouri | 16a9940 | 2019-07-29 16:37:30 -0700 | [diff] [blame] | 34 | #include <sys/types.h> |
Vishnu Nair | f19544f | 2020-02-03 11:23:26 -0800 | [diff] [blame^] | 35 | #include "GLShadowTexture.h" |
Alec Mouri | 16a9940 | 2019-07-29 16:37:30 -0700 | [diff] [blame] | 36 | #include "ImageManager.h" |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 37 | |
Peiyong Lin | f11f39b | 2018-09-05 14:37:41 -0700 | [diff] [blame] | 38 | #define EGL_NO_CONFIG ((EGLConfig)0) |
| 39 | |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 40 | namespace android { |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 41 | |
Peiyong Lin | 833074a | 2018-08-28 11:53:54 -0700 | [diff] [blame] | 42 | namespace renderengine { |
| 43 | |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 44 | class Mesh; |
Mathias Agopian | 49457ac | 2013-08-14 18:20:17 -0700 | [diff] [blame] | 45 | class Texture; |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 46 | |
Peiyong Lin | 833074a | 2018-08-28 11:53:54 -0700 | [diff] [blame] | 47 | namespace gl { |
Lloyd Pique | 144e116 | 2017-12-20 16:44:52 -0800 | [diff] [blame] | 48 | |
Peiyong Lin | f1bada9 | 2018-08-29 09:39:31 -0700 | [diff] [blame] | 49 | class GLImage; |
Lucas Dupin | 19c8f0e | 2019-11-25 17:55:44 -0800 | [diff] [blame] | 50 | class BlurFilter; |
Peiyong Lin | f1bada9 | 2018-08-29 09:39:31 -0700 | [diff] [blame] | 51 | |
Peiyong Lin | 7e219eb | 2018-12-03 05:40:42 -0800 | [diff] [blame] | 52 | class GLESRenderEngine : public impl::RenderEngine { |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 53 | public: |
Peiyong Lin | 4137a1d | 2019-10-09 10:39:09 -0700 | [diff] [blame] | 54 | static std::unique_ptr<GLESRenderEngine> create(const RenderEngineCreationArgs& args); |
Peiyong Lin | f11f39b | 2018-09-05 14:37:41 -0700 | [diff] [blame] | 55 | |
Peiyong Lin | 4137a1d | 2019-10-09 10:39:09 -0700 | [diff] [blame] | 56 | GLESRenderEngine(const RenderEngineCreationArgs& args, EGLDisplay display, EGLConfig config, |
| 57 | EGLContext ctxt, EGLSurface dummy, EGLContext protectedContext, |
| 58 | EGLSurface protectedDummy); |
Alec Mouri | d43ccab | 2019-03-13 12:23:45 -0700 | [diff] [blame] | 59 | ~GLESRenderEngine() override EXCLUDES(mRenderingMutex); |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 60 | |
Peiyong Lin | f1bada9 | 2018-08-29 09:39:31 -0700 | [diff] [blame] | 61 | void primeCache() const override; |
Peiyong Lin | 60bedb5 | 2018-09-05 10:47:31 -0700 | [diff] [blame] | 62 | void genTextures(size_t count, uint32_t* names) override; |
| 63 | void deleteTextures(size_t count, uint32_t const* names) override; |
Peiyong Lin | e5a9a7f | 2018-08-30 15:32:13 -0700 | [diff] [blame] | 64 | void bindExternalTextureImage(uint32_t texName, const Image& image) override; |
Alec Mouri | d7b3a8b | 2019-03-21 11:44:18 -0700 | [diff] [blame] | 65 | status_t bindExternalTextureBuffer(uint32_t texName, const sp<GraphicBuffer>& buffer, |
| 66 | const sp<Fence>& fence) EXCLUDES(mRenderingMutex); |
Alec Mouri | 16a9940 | 2019-07-29 16:37:30 -0700 | [diff] [blame] | 67 | void cacheExternalTextureBuffer(const sp<GraphicBuffer>& buffer) EXCLUDES(mRenderingMutex); |
Alec Mouri | f049727 | 2019-03-11 15:53:11 -0700 | [diff] [blame] | 68 | void unbindExternalTextureBuffer(uint64_t bufferId) EXCLUDES(mRenderingMutex); |
Peiyong Lin | e5a9a7f | 2018-08-30 15:32:13 -0700 | [diff] [blame] | 69 | status_t bindFrameBuffer(Framebuffer* framebuffer) override; |
| 70 | void unbindFrameBuffer(Framebuffer* framebuffer) override; |
Peiyong Lin | f1bada9 | 2018-08-29 09:39:31 -0700 | [diff] [blame] | 71 | |
Peiyong Lin | fb530cf | 2018-12-15 05:07:38 +0000 | [diff] [blame] | 72 | bool isProtected() const override { return mInProtectedContext; } |
| 73 | bool supportsProtectedContent() const override; |
| 74 | bool useProtectedContext(bool useProtectedContext) override; |
Vishnu Nair | 9b079a2 | 2020-01-21 14:36:08 -0800 | [diff] [blame] | 75 | status_t drawLayers(const DisplaySettings& display, |
| 76 | const std::vector<const LayerSettings*>& layers, |
Alec Mouri | fe0d72b | 2019-03-21 14:05:56 -0700 | [diff] [blame] | 77 | ANativeWindowBuffer* buffer, const bool useFramebufferCache, |
Alec Mouri | 3d7c561 | 2019-07-09 13:51:37 -0700 | [diff] [blame] | 78 | base::unique_fd&& bufferFence, base::unique_fd* drawFence) override; |
Alec Mouri | 6e57f68 | 2018-09-29 20:45:08 -0700 | [diff] [blame] | 79 | |
Peiyong Lin | f11f39b | 2018-09-05 14:37:41 -0700 | [diff] [blame] | 80 | EGLDisplay getEGLDisplay() const { return mEGLDisplay; } |
Alec Mouri | da4cf3b | 2019-02-12 15:33:01 -0800 | [diff] [blame] | 81 | // Creates an output image for rendering to |
Alec Mouri | fe0d72b | 2019-03-21 14:05:56 -0700 | [diff] [blame] | 82 | EGLImageKHR createFramebufferImageIfNeeded(ANativeWindowBuffer* nativeBuffer, bool isProtected, |
Alec Mouri | ef44c2d | 2019-07-15 15:27:22 -0700 | [diff] [blame] | 83 | bool useFramebufferCache) |
| 84 | EXCLUDES(mFramebufferImageCacheMutex); |
Peiyong Lin | f11f39b | 2018-09-05 14:37:41 -0700 | [diff] [blame] | 85 | |
Alec Mouri | d43ccab | 2019-03-13 12:23:45 -0700 | [diff] [blame] | 86 | // Test-only methods |
| 87 | // Returns true iff mImageCache contains an image keyed by bufferId |
| 88 | bool isImageCachedForTesting(uint64_t bufferId) EXCLUDES(mRenderingMutex); |
| 89 | // Returns true iff mFramebufferImageCache contains an image keyed by bufferId |
Alec Mouri | ef44c2d | 2019-07-15 15:27:22 -0700 | [diff] [blame] | 90 | bool isFramebufferImageCachedForTesting(uint64_t bufferId) |
| 91 | EXCLUDES(mFramebufferImageCacheMutex); |
Alec Mouri | 16a9940 | 2019-07-29 16:37:30 -0700 | [diff] [blame] | 92 | // These are wrappers around public methods above, but exposing Barrier |
| 93 | // objects so that tests can block. |
| 94 | std::shared_ptr<ImageManager::Barrier> cacheExternalTextureBufferForTesting( |
| 95 | const sp<GraphicBuffer>& buffer); |
| 96 | std::shared_ptr<ImageManager::Barrier> unbindExternalTextureBufferForTesting(uint64_t bufferId); |
Alec Mouri | d43ccab | 2019-03-13 12:23:45 -0700 | [diff] [blame] | 97 | |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 98 | protected: |
Alec Mouri | 820c740 | 2019-01-23 13:02:39 -0800 | [diff] [blame] | 99 | Framebuffer* getFramebufferForDrawing() override; |
Alec Mouri | ef44c2d | 2019-07-15 15:27:22 -0700 | [diff] [blame] | 100 | void dump(std::string& result) override EXCLUDES(mRenderingMutex) |
| 101 | EXCLUDES(mFramebufferImageCacheMutex); |
Peiyong Lin | e5a9a7f | 2018-08-30 15:32:13 -0700 | [diff] [blame] | 102 | size_t getMaxTextureSize() const override; |
| 103 | size_t getMaxViewportDims() const override; |
| 104 | |
| 105 | private: |
Peiyong Lin | f11f39b | 2018-09-05 14:37:41 -0700 | [diff] [blame] | 106 | enum GlesVersion { |
| 107 | GLES_VERSION_1_0 = 0x10000, |
| 108 | GLES_VERSION_1_1 = 0x10001, |
| 109 | GLES_VERSION_2_0 = 0x20000, |
| 110 | GLES_VERSION_3_0 = 0x30000, |
| 111 | }; |
| 112 | |
Alec Mouri | 8002fca | 2019-06-28 15:24:13 -0700 | [diff] [blame] | 113 | static EGLConfig chooseEglConfig(EGLDisplay display, int format, bool logConfig); |
Peiyong Lin | f11f39b | 2018-09-05 14:37:41 -0700 | [diff] [blame] | 114 | static GlesVersion parseGlesVersion(const char* str); |
Peiyong Lin | a5e9f1b | 2018-11-27 22:49:37 -0800 | [diff] [blame] | 115 | static EGLContext createEglContext(EGLDisplay display, EGLConfig config, |
Peiyong Lin | fb530cf | 2018-12-15 05:07:38 +0000 | [diff] [blame] | 116 | EGLContext shareContext, bool useContextPriority, |
| 117 | Protection protection); |
Peiyong Lin | a5e9f1b | 2018-11-27 22:49:37 -0800 | [diff] [blame] | 118 | static EGLSurface createDummyEglPbufferSurface(EGLDisplay display, EGLConfig config, |
Peiyong Lin | fb530cf | 2018-12-15 05:07:38 +0000 | [diff] [blame] | 119 | int hwcFormat, Protection protection); |
Alec Mouri | 8002fca | 2019-06-28 15:24:13 -0700 | [diff] [blame] | 120 | std::unique_ptr<Framebuffer> createFramebuffer(); |
| 121 | std::unique_ptr<Image> createImage(); |
| 122 | void checkErrors() const; |
Lucas Dupin | 19c8f0e | 2019-11-25 17:55:44 -0800 | [diff] [blame] | 123 | void checkErrors(const char* tag) const; |
Peiyong Lin | 1c09761 | 2019-03-22 16:21:46 -0700 | [diff] [blame] | 124 | void setScissor(const Rect& region); |
| 125 | void disableScissor(); |
Alec Mouri | 554d06e | 2018-12-20 00:15:33 -0800 | [diff] [blame] | 126 | bool waitSync(EGLSyncKHR sync, EGLint flags); |
Alec Mouri | 16a9940 | 2019-07-29 16:37:30 -0700 | [diff] [blame] | 127 | status_t cacheExternalTextureBufferInternal(const sp<GraphicBuffer>& buffer) |
| 128 | EXCLUDES(mRenderingMutex); |
| 129 | void unbindExternalTextureBufferInternal(uint64_t bufferId) EXCLUDES(mRenderingMutex); |
Peiyong Lin | f11f39b | 2018-09-05 14:37:41 -0700 | [diff] [blame] | 130 | |
Peiyong Lin | e5a9a7f | 2018-08-30 15:32:13 -0700 | [diff] [blame] | 131 | // A data space is considered HDR data space if it has BT2020 color space |
| 132 | // with PQ or HLG transfer function. |
| 133 | bool isHdrDataSpace(const ui::Dataspace dataSpace) const; |
| 134 | bool needsXYZTransformMatrix() const; |
Alec Mouri | 1089aed | 2018-10-25 21:33:57 -0700 | [diff] [blame] | 135 | // Defines the viewport, and sets the projection matrix to the projection |
| 136 | // defined by the clip. |
| 137 | void setViewportAndProjection(Rect viewport, Rect clip); |
Alec Mouri | 539319f | 2018-12-19 17:56:23 -0800 | [diff] [blame] | 138 | // Evicts stale images from the buffer cache. |
| 139 | void evictImages(const std::vector<LayerSettings>& layers); |
Alec Mouri | 7c94edb | 2018-12-03 21:23:26 -0800 | [diff] [blame] | 140 | // Computes the cropping window for the layer and sets up cropping |
| 141 | // coordinates for the mesh. |
| 142 | FloatRect setupLayerCropping(const LayerSettings& layer, Mesh& mesh); |
Peiyong Lin | e5a9a7f | 2018-08-30 15:32:13 -0700 | [diff] [blame] | 143 | |
Peiyong Lin | 1c09761 | 2019-03-22 16:21:46 -0700 | [diff] [blame] | 144 | // We do a special handling for rounded corners when it's possible to turn off blending |
| 145 | // for the majority of the layer. The rounded corners needs to turn on blending such that |
| 146 | // we can set the alpha value correctly, however, only the corners need this, and since |
| 147 | // blending is an expensive operation, we want to turn off blending when it's not necessary. |
| 148 | void handleRoundedCorners(const DisplaySettings& display, const LayerSettings& layer, |
| 149 | const Mesh& mesh); |
Alec Mouri | 8002fca | 2019-06-28 15:24:13 -0700 | [diff] [blame] | 150 | base::unique_fd flush(); |
| 151 | bool finish(); |
| 152 | bool waitFence(base::unique_fd fenceFd); |
| 153 | void clearWithColor(float red, float green, float blue, float alpha); |
| 154 | void fillRegionWithColor(const Region& region, float red, float green, float blue, float alpha); |
Vishnu Nair | 16efdbf | 2019-12-10 11:55:42 -0800 | [diff] [blame] | 155 | void handleShadow(const FloatRect& casterRect, float casterCornerRadius, |
| 156 | const ShadowSettings& shadowSettings); |
Alec Mouri | 8002fca | 2019-06-28 15:24:13 -0700 | [diff] [blame] | 157 | void setupLayerBlending(bool premultipliedAlpha, bool opaque, bool disableTexture, |
| 158 | const half4& color, float cornerRadius); |
| 159 | void setupLayerTexturing(const Texture& texture); |
| 160 | void setupFillWithColor(float r, float g, float b, float a); |
| 161 | void setColorTransform(const mat4& colorTransform); |
| 162 | void disableTexturing(); |
| 163 | void disableBlending(); |
| 164 | void setupCornerRadiusCropSize(float width, float height); |
| 165 | |
| 166 | // HDR and color management related functions and state |
| 167 | void setSourceY410BT2020(bool enable); |
| 168 | void setSourceDataSpace(ui::Dataspace source); |
| 169 | void setOutputDataSpace(ui::Dataspace dataspace); |
| 170 | void setDisplayMaxLuminance(const float maxLuminance); |
| 171 | |
| 172 | // drawing |
| 173 | void drawMesh(const Mesh& mesh); |
Peiyong Lin | 1c09761 | 2019-03-22 16:21:46 -0700 | [diff] [blame] | 174 | |
Peiyong Lin | f11f39b | 2018-09-05 14:37:41 -0700 | [diff] [blame] | 175 | EGLDisplay mEGLDisplay; |
| 176 | EGLConfig mEGLConfig; |
| 177 | EGLContext mEGLContext; |
Alec Mouri | 0a9c7b8 | 2018-11-16 13:05:25 -0800 | [diff] [blame] | 178 | EGLSurface mDummySurface; |
Peiyong Lin | fb530cf | 2018-12-15 05:07:38 +0000 | [diff] [blame] | 179 | EGLContext mProtectedEGLContext; |
| 180 | EGLSurface mProtectedDummySurface; |
Peiyong Lin | e5a9a7f | 2018-08-30 15:32:13 -0700 | [diff] [blame] | 181 | GLuint mProtectedTexName; |
| 182 | GLint mMaxViewportDims[2]; |
| 183 | GLint mMaxTextureSize; |
| 184 | GLuint mVpWidth; |
| 185 | GLuint mVpHeight; |
| 186 | Description mState; |
Vishnu Nair | f19544f | 2020-02-03 11:23:26 -0800 | [diff] [blame^] | 187 | GLShadowTexture mShadowTexture; |
Peiyong Lin | e5a9a7f | 2018-08-30 15:32:13 -0700 | [diff] [blame] | 188 | |
Peiyong Lin | 70b26ce | 2018-09-18 19:02:39 -0700 | [diff] [blame] | 189 | mat4 mSrgbToXyz; |
Peiyong Lin | 70b26ce | 2018-09-18 19:02:39 -0700 | [diff] [blame] | 190 | mat4 mDisplayP3ToXyz; |
Valerie Hau | eb8e076 | 2018-11-06 10:10:42 -0800 | [diff] [blame] | 191 | mat4 mBt2020ToXyz; |
Peiyong Lin | e5a9a7f | 2018-08-30 15:32:13 -0700 | [diff] [blame] | 192 | mat4 mXyzToSrgb; |
| 193 | mat4 mXyzToDisplayP3; |
| 194 | mat4 mXyzToBt2020; |
Valerie Hau | eb8e076 | 2018-11-06 10:10:42 -0800 | [diff] [blame] | 195 | mat4 mSrgbToDisplayP3; |
| 196 | mat4 mSrgbToBt2020; |
| 197 | mat4 mDisplayP3ToSrgb; |
| 198 | mat4 mDisplayP3ToBt2020; |
| 199 | mat4 mBt2020ToSrgb; |
| 200 | mat4 mBt2020ToDisplayP3; |
Peiyong Lin | e5a9a7f | 2018-08-30 15:32:13 -0700 | [diff] [blame] | 201 | |
Peiyong Lin | fb530cf | 2018-12-15 05:07:38 +0000 | [diff] [blame] | 202 | bool mInProtectedContext = false; |
Alec Mouri | 554d06e | 2018-12-20 00:15:33 -0800 | [diff] [blame] | 203 | // If set to true, then enables tracing flush() and finish() to systrace. |
| 204 | bool mTraceGpuCompletion = false; |
Alec Mouri | da4cf3b | 2019-02-12 15:33:01 -0800 | [diff] [blame] | 205 | // Maximum size of mFramebufferImageCache. If more images would be cached, then (approximately) |
| 206 | // the last recently used buffer should be kicked out. |
| 207 | uint32_t mFramebufferImageCacheSize = 0; |
| 208 | |
| 209 | // Cache of output images, keyed by corresponding GraphicBuffer ID. |
Alec Mouri | ef44c2d | 2019-07-15 15:27:22 -0700 | [diff] [blame] | 210 | std::deque<std::pair<uint64_t, EGLImageKHR>> mFramebufferImageCache |
| 211 | GUARDED_BY(mFramebufferImageCacheMutex); |
| 212 | // The only reason why we have this mutex is so that we don't segfault when |
| 213 | // dumping info. |
| 214 | std::mutex mFramebufferImageCacheMutex; |
Peiyong Lin | fb06930 | 2018-04-25 14:34:31 -0700 | [diff] [blame] | 215 | |
| 216 | // Current dataspace of layer being rendered |
| 217 | ui::Dataspace mDataSpace = ui::Dataspace::UNKNOWN; |
| 218 | |
| 219 | // Current output dataspace of the render engine |
| 220 | ui::Dataspace mOutputDataSpace = ui::Dataspace::UNKNOWN; |
| 221 | |
Peiyong Lin | 13effd1 | 2018-07-24 17:01:47 -0700 | [diff] [blame] | 222 | // Whether device supports color management, currently color management |
| 223 | // supports sRGB, DisplayP3 color spaces. |
| 224 | const bool mUseColorManagement = false; |
Alec Mouri | 554d06e | 2018-12-20 00:15:33 -0800 | [diff] [blame] | 225 | |
Alec Mouri | 539319f | 2018-12-19 17:56:23 -0800 | [diff] [blame] | 226 | // Cache of GL images that we'll store per GraphicBuffer ID |
Alec Mouri | f049727 | 2019-03-11 15:53:11 -0700 | [diff] [blame] | 227 | std::unordered_map<uint64_t, std::unique_ptr<Image>> mImageCache GUARDED_BY(mRenderingMutex); |
| 228 | // Mutex guarding rendering operations, so that: |
| 229 | // 1. GL operations aren't interleaved, and |
| 230 | // 2. Internal state related to rendering that is potentially modified by |
| 231 | // multiple threads is guaranteed thread-safe. |
| 232 | std::mutex mRenderingMutex; |
| 233 | |
Alec Mouri | 820c740 | 2019-01-23 13:02:39 -0800 | [diff] [blame] | 234 | std::unique_ptr<Framebuffer> mDrawingBuffer; |
| 235 | |
Lucas Dupin | 19c8f0e | 2019-11-25 17:55:44 -0800 | [diff] [blame] | 236 | // Blur effect processor, only instantiated when a layer requests it. |
| 237 | BlurFilter* mBlurFilter = nullptr; |
| 238 | |
Alec Mouri | 554d06e | 2018-12-20 00:15:33 -0800 | [diff] [blame] | 239 | class FlushTracer { |
| 240 | public: |
| 241 | FlushTracer(GLESRenderEngine* engine); |
| 242 | ~FlushTracer(); |
| 243 | void queueSync(EGLSyncKHR sync) EXCLUDES(mMutex); |
| 244 | |
| 245 | struct QueueEntry { |
| 246 | EGLSyncKHR mSync = nullptr; |
| 247 | uint64_t mFrameNum = 0; |
| 248 | }; |
| 249 | |
| 250 | private: |
| 251 | void loop(); |
| 252 | GLESRenderEngine* const mEngine; |
| 253 | std::thread mThread; |
| 254 | std::condition_variable_any mCondition; |
| 255 | std::mutex mMutex; |
| 256 | std::queue<QueueEntry> mQueue GUARDED_BY(mMutex); |
| 257 | uint64_t mFramesQueued GUARDED_BY(mMutex) = 0; |
| 258 | bool mRunning = true; |
| 259 | }; |
| 260 | friend class FlushTracer; |
Alec Mouri | 16a9940 | 2019-07-29 16:37:30 -0700 | [diff] [blame] | 261 | friend class ImageManager; |
Lucas Dupin | 19c8f0e | 2019-11-25 17:55:44 -0800 | [diff] [blame] | 262 | friend class GLFramebuffer; |
| 263 | friend class BlurFilter; |
| 264 | friend class GaussianBlurFilter; |
| 265 | friend class LensBlurFilter; |
| 266 | friend class GenericProgram; |
Alec Mouri | 554d06e | 2018-12-20 00:15:33 -0800 | [diff] [blame] | 267 | std::unique_ptr<FlushTracer> mFlushTracer; |
Alec Mouri | 16a9940 | 2019-07-29 16:37:30 -0700 | [diff] [blame] | 268 | std::unique_ptr<ImageManager> mImageManager = std::make_unique<ImageManager>(this); |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 269 | }; |
| 270 | |
Peiyong Lin | 46080ef | 2018-10-26 18:43:14 -0700 | [diff] [blame] | 271 | } // namespace gl |
| 272 | } // namespace renderengine |
| 273 | } // namespace android |
Mathias Agopian | 3f84483 | 2013-08-07 21:24:32 -0700 | [diff] [blame] | 274 | |
Peiyong Lin | 7e219eb | 2018-12-03 05:40:42 -0800 | [diff] [blame] | 275 | #endif /* SF_GLESRENDERENGINE_H_ */ |