Nolan Scobie | fc125ec | 2024-03-11 20:08:27 -0400 | [diff] [blame] | 1 | /* |
| 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 | |
| 23 | namespace android::renderengine::skia { |
| 24 | |
| 25 | class GaneshGpuContext : public SkiaGpuContext { |
| 26 | public: |
| 27 | GaneshGpuContext(sk_sp<GrDirectContext> grContext); |
Nolan Scobie | 2526b2f | 2024-04-16 15:12:22 -0400 | [diff] [blame] | 28 | ~GaneshGpuContext() override; |
Nolan Scobie | fc125ec | 2024-03-11 20:08:27 -0400 | [diff] [blame] | 29 | |
| 30 | sk_sp<GrDirectContext> grDirectContext() override; |
| 31 | |
Nolan Scobie | ca05028 | 2024-03-15 13:27:06 -0400 | [diff] [blame] | 32 | std::unique_ptr<SkiaBackendTexture> makeBackendTexture(AHardwareBuffer* buffer, |
| 33 | bool isOutputBuffer) override; |
| 34 | |
Nolan Scobie | fc125ec | 2024-03-11 20:08:27 -0400 | [diff] [blame] | 35 | sk_sp<SkSurface> createRenderTarget(SkImageInfo imageInfo) override; |
| 36 | |
| 37 | size_t getMaxRenderTargetSize() const override; |
| 38 | size_t getMaxTextureSize() const override; |
Nolan Scobie | 17ffe90 | 2024-03-25 11:07:30 -0400 | [diff] [blame] | 39 | bool isAbandonedOrDeviceLost() override; |
Nolan Scobie | fc125ec | 2024-03-11 20:08:27 -0400 | [diff] [blame] | 40 | void setResourceCacheLimit(size_t maxResourceBytes) override; |
| 41 | |
Nolan Scobie | fc125ec | 2024-03-11 20:08:27 -0400 | [diff] [blame] | 42 | void purgeUnlockedScratchResources() override; |
| 43 | void resetContextIfApplicable() override; |
| 44 | |
| 45 | void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const override; |
| 46 | |
| 47 | private: |
| 48 | DISALLOW_COPY_AND_ASSIGN(GaneshGpuContext); |
| 49 | |
| 50 | const sk_sp<GrDirectContext> mGrContext; |
| 51 | }; |
| 52 | |
| 53 | } // namespace android::renderengine::skia |