blob: 1e42b80c1056e588105ad32785ec75ec6b59abf1 [file] [log] [blame]
Ian Elliott1f0911e2022-09-09 16:31:47 -06001/*
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 Elliott32f9e692022-11-22 15:30:29 -070020// 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 Elliott1f0911e2022-09-09 16:31:47 -060024#include <vk/GrVkBackendContext.h>
25
26#include "SkiaRenderEngine.h"
27
28namespace android {
29namespace renderengine {
30namespace skia {
31
32class SkiaVkRenderEngine : public SkiaRenderEngine {
33public:
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
41protected:
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
51private:
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 Elliott32f9e692022-11-22 15:30:29 -070062#endif // RE_SKIAVK
63#endif // SF_SKIAVKRENDERENGINE_H_