Ian Elliott | 1f0911e | 2022-09-09 16:31:47 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2022 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 | #ifndef SF_SKIAVKRENDERENGINE_H_ |
| 18 | #define SF_SKIAVKRENDERENGINE_H_ |
| 19 | |
Ian Elliott | 32f9e69 | 2022-11-22 15:30:29 -0700 | [diff] [blame] | 20 | // Allow the SkiaVkRenderEngine class to not be compiled, to save space |
| 21 | // NOTE: In order to build this class, define `RE_SKIAVK` in a build file. |
| 22 | #ifdef RE_SKIAVK |
| 23 | |
Ian Elliott | 1f0911e | 2022-09-09 16:31:47 -0600 | [diff] [blame] | 24 | #include <vk/GrVkBackendContext.h> |
| 25 | |
| 26 | #include "SkiaRenderEngine.h" |
| 27 | |
| 28 | namespace android { |
| 29 | namespace renderengine { |
| 30 | namespace skia { |
| 31 | |
| 32 | class SkiaVkRenderEngine : public SkiaRenderEngine { |
| 33 | public: |
| 34 | // Returns false if Vulkan implementation can't support SkiaVkRenderEngine. |
| 35 | static bool canSupportSkiaVkRenderEngine(); |
| 36 | static std::unique_ptr<SkiaVkRenderEngine> create(const RenderEngineCreationArgs& args); |
| 37 | ~SkiaVkRenderEngine() override; |
| 38 | |
| 39 | int getContextPriority() override; |
| 40 | |
| 41 | protected: |
| 42 | // Implementations of abstract SkiaRenderEngine functions specific to |
| 43 | // rendering backend |
| 44 | virtual SkiaRenderEngine::Contexts createDirectContexts(const GrContextOptions& options); |
| 45 | bool supportsProtectedContentImpl() const override; |
| 46 | bool useProtectedContextImpl(GrProtected isProtected) override; |
| 47 | void waitFence(GrDirectContext* grContext, base::borrowed_fd fenceFd) override; |
| 48 | base::unique_fd flushAndSubmit(GrDirectContext* context) override; |
| 49 | void appendBackendSpecificInfoToDump(std::string& result) override; |
| 50 | |
| 51 | private: |
| 52 | SkiaVkRenderEngine(const RenderEngineCreationArgs& args); |
| 53 | base::unique_fd flush(); |
| 54 | |
| 55 | GrVkBackendContext mBackendContext; |
| 56 | }; |
| 57 | |
| 58 | } // namespace skia |
| 59 | } // namespace renderengine |
| 60 | } // namespace android |
| 61 | |
Ian Elliott | 32f9e69 | 2022-11-22 15:30:29 -0700 | [diff] [blame] | 62 | #endif // RE_SKIAVK |
| 63 | #endif // SF_SKIAVKRENDERENGINE_H_ |