blob: 91fe3f6cf273a7659d31e3f18eebb628434e8550 [file] [log] [blame]
Nader Jawada3521852023-01-30 20:23:46 -08001/*
2 * Copyright (C) 2013 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#ifndef HARDWAREBUFFERRENDERER_H_
17#define HARDWAREBUFFERRENDERER_H_
18
19#include <android-base/unique_fd.h>
20#include <android/hardware_buffer.h>
21
22#include "SkColorSpace.h"
23#include "SkMatrix.h"
24#include "SkSurface.h"
25
26namespace android {
27namespace uirenderer {
28namespace renderthread {
29
30using namespace android::uirenderer::renderthread;
31
32using RenderCallback = std::function<void(android::base::unique_fd&&, int)>;
33
34class RenderProxy;
35
36class HardwareBufferRenderParams {
37public:
38 HardwareBufferRenderParams() = default;
39 HardwareBufferRenderParams(const SkMatrix& transform, const sk_sp<SkColorSpace>& colorSpace,
40 RenderCallback&& callback)
41 : mTransform(transform)
42 , mColorSpace(colorSpace)
43 , mRenderCallback(std::move(callback)) {}
44 const SkMatrix& getTransform() const { return mTransform; }
45 sk_sp<SkColorSpace> getColorSpace() const { return mColorSpace; }
46
47 void invokeRenderCallback(android::base::unique_fd&& fenceFd, int status) {
48 if (mRenderCallback) {
49 std::invoke(mRenderCallback, std::move(fenceFd), status);
50 }
51 }
52
53private:
54 SkMatrix mTransform = SkMatrix::I();
55 sk_sp<SkColorSpace> mColorSpace = SkColorSpace::MakeSRGB();
56 RenderCallback mRenderCallback = nullptr;
57};
58
59} // namespace renderthread
60} // namespace uirenderer
61} // namespace android
62#endif // HARDWAREBUFFERRENDERER_H_