blob: ec0162d983663500e90136dfc814d786ab387128 [file] [log] [blame]
Nolan Scobiefc125ec2024-03-11 20:08:27 -04001/*
2 * Copyright 2024 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#pragma once
18
19#include "SkiaGpuContext.h"
20
21#include <android-base/macros.h>
22
23namespace android::renderengine::skia {
24
25class GaneshGpuContext : public SkiaGpuContext {
26public:
27 GaneshGpuContext(sk_sp<GrDirectContext> grContext);
28 ~GaneshGpuContext() override = default;
29
30 sk_sp<GrDirectContext> grDirectContext() override;
31
Nolan Scobieca050282024-03-15 13:27:06 -040032 std::unique_ptr<SkiaBackendTexture> makeBackendTexture(AHardwareBuffer* buffer,
33 bool isOutputBuffer) override;
34
Nolan Scobiefc125ec2024-03-11 20:08:27 -040035 sk_sp<SkSurface> createRenderTarget(SkImageInfo imageInfo) override;
36
37 size_t getMaxRenderTargetSize() const override;
38 size_t getMaxTextureSize() const override;
39 bool isAbandoned() override;
40 void setResourceCacheLimit(size_t maxResourceBytes) override;
41
42 void finishRenderingAndAbandonContext() override;
43 void purgeUnlockedScratchResources() override;
44 void resetContextIfApplicable() override;
45
46 void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const override;
47
48private:
49 DISALLOW_COPY_AND_ASSIGN(GaneshGpuContext);
50
51 const sk_sp<GrDirectContext> mGrContext;
52};
53
54} // namespace android::renderengine::skia