blob: 5cf8647801927e5399785ea9119e72a571426031 [file] [log] [blame]
Nolan Scobieca050282024-03-15 13:27:06 -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 "SkiaBackendTexture.h"
20#include "ui/GraphicTypes.h"
21
22#include <include/android/GrAHardwareBufferUtils.h>
23#include <include/core/SkColorSpace.h>
24#include <include/gpu/GrDirectContext.h>
25
26#include <android-base/macros.h>
27
28namespace android::renderengine::skia {
29
30class GaneshBackendTexture : public SkiaBackendTexture {
31public:
32 // Creates an internal GrBackendTexture whose contents come from the provided buffer.
33 GaneshBackendTexture(sk_sp<GrDirectContext> grContext, AHardwareBuffer* buffer,
34 bool isOutputBuffer);
35
36 ~GaneshBackendTexture() override;
37
38 sk_sp<SkImage> makeImage(SkAlphaType alphaType, ui::Dataspace dataspace,
39 TextureReleaseProc releaseImageProc,
40 ReleaseContext releaseContext) override;
41
42 sk_sp<SkSurface> makeSurface(ui::Dataspace dataspace, TextureReleaseProc releaseSurfaceProc,
43 ReleaseContext releaseContext) override;
44
45private:
46 DISALLOW_COPY_AND_ASSIGN(GaneshBackendTexture);
47
48 void logFatalTexture(const char* msg, ui::Dataspace dataspace, SkColorType colorType);
49
50 const sk_sp<GrDirectContext> mGrContext;
51 GrBackendTexture mBackendTexture;
52 GrAHardwareBufferUtils::DeleteImageProc mDeleteProc;
53 GrAHardwareBufferUtils::UpdateImageProc mUpdateProc;
54 GrAHardwareBufferUtils::TexImageCtx mImageCtx;
55};
56
57} // namespace android::renderengine::skia