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 20 #include <vk/GrVkBackendContext.h> 21 22 #include "SkiaRenderEngine.h" 23 24 namespace android { 25 namespace renderengine { 26 namespace skia { 27 28 class SkiaVkRenderEngine : public SkiaRenderEngine { 29 public: 30 // Returns false if Vulkan implementation can't support SkiaVkRenderEngine. 31 static bool canSupportSkiaVkRenderEngine(); 32 static std::unique_ptr<SkiaVkRenderEngine> create(const RenderEngineCreationArgs& args); 33 ~SkiaVkRenderEngine() override; 34 35 int getContextPriority() override; 36 37 protected: 38 // Implementations of abstract SkiaRenderEngine functions specific to 39 // rendering backend 40 virtual SkiaRenderEngine::Contexts createDirectContexts(const GrContextOptions& options); 41 bool supportsProtectedContentImpl() const override; 42 bool useProtectedContextImpl(GrProtected isProtected) override; 43 void waitFence(GrDirectContext* grContext, base::borrowed_fd fenceFd) override; 44 base::unique_fd flushAndSubmit(GrDirectContext* context) override; 45 void appendBackendSpecificInfoToDump(std::string& result) override; 46 47 private: 48 SkiaVkRenderEngine(const RenderEngineCreationArgs& args); 49 base::unique_fd flush(); 50 51 GrVkBackendContext mBackendContext; 52 }; 53 54 } // namespace skia 55 } // namespace renderengine 56 } // namespace android 57 58 #endif 59