blob: 59001eccc2f7cb494dd0890637a97bf8966cf706 [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
32 sk_sp<SkSurface> createRenderTarget(SkImageInfo imageInfo) override;
33
34 size_t getMaxRenderTargetSize() const override;
35 size_t getMaxTextureSize() const override;
36 bool isAbandoned() override;
37 void setResourceCacheLimit(size_t maxResourceBytes) override;
38
39 void finishRenderingAndAbandonContext() override;
40 void purgeUnlockedScratchResources() override;
41 void resetContextIfApplicable() override;
42
43 void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const override;
44
45private:
46 DISALLOW_COPY_AND_ASSIGN(GaneshGpuContext);
47
48 const sk_sp<GrDirectContext> mGrContext;
49};
50
51} // namespace android::renderengine::skia