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); 28 ~GaneshGpuContext() override; 29 30 sk_sp<GrDirectContext> grDirectContext() override; 31 32 std::unique_ptr<SkiaBackendTexture> makeBackendTexture(AHardwareBuffer* buffer, 33 bool isOutputBuffer) override; 34 35 sk_sp<SkSurface> createRenderTarget(SkImageInfo imageInfo) override; 36 37 size_t getMaxRenderTargetSize() const override; 38 size_t getMaxTextureSize() const override; 39 bool isAbandonedOrDeviceLost() override; 40 void setResourceCacheLimit(size_t maxResourceBytes) override; 41 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 54