blob: aeb1a822d4d928953b55daf431bcc74c6ae089d1 [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);
Nolan Scobie2526b2f2024-04-16 15:12:22 -040028 ~GaneshGpuContext() override;
Nolan Scobiefc125ec2024-03-11 20:08:27 -040029
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;
Nolan Scobie17ffe902024-03-25 11:07:30 -040039 bool isAbandonedOrDeviceLost() override;
Nolan Scobiefc125ec2024-03-11 20:08:27 -040040 void setResourceCacheLimit(size_t maxResourceBytes) override;
41
Nolan Scobiefc125ec2024-03-11 20:08:27 -040042 void purgeUnlockedScratchResources() override;
43 void resetContextIfApplicable() override;
44
45 void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const override;
46
47private:
48 DISALLOW_COPY_AND_ASSIGN(GaneshGpuContext);
49
50 const sk_sp<GrDirectContext> mGrContext;
51};
52
53} // namespace android::renderengine::skia