blob: ba882520118f2416eb9c19428f5822d7365d8eb3 [file] [log] [blame]
Sally Qi147581b2023-06-27 11:55:34 -07001/**
2 * Copyright (C) 2023 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 "Utils/OverlayUtils.h"
20
21#include <ui/Size.h>
22#include <utils/StrongPointer.h>
23
24class SkCanvas;
25
26namespace android {
27class HdrSdrRatioOverlay {
Ady Abrahamddba9342023-10-02 16:28:03 -070028private:
29 // Effectively making the constructor private, while keeping std::make_unique work
30 struct ConstructorTag {};
31
Sally Qi147581b2023-06-27 11:55:34 -070032public:
Ady Abrahamddba9342023-10-02 16:28:03 -070033 static std::unique_ptr<HdrSdrRatioOverlay> create();
34
Sally Qi147581b2023-06-27 11:55:34 -070035 void setLayerStack(ui::LayerStack);
36 void setViewport(ui::Size);
37 void animate();
38 void changeHdrSdrRatio(float currentRatio);
39
Ady Abrahamddba9342023-10-02 16:28:03 -070040 HdrSdrRatioOverlay(ConstructorTag);
41
Sally Qi147581b2023-06-27 11:55:34 -070042private:
Ady Abrahamddba9342023-10-02 16:28:03 -070043 bool initCheck() const;
Sally Qi147581b2023-06-27 11:55:34 -070044
Sally Qi127d99c2023-07-26 20:31:44 +080045 static sp<GraphicBuffer> draw(float currentHdrSdrRatio, SkColor, ui::Transform::RotationFlags,
46 sp<GraphicBuffer>& ringBufer);
Sally Qi147581b2023-06-27 11:55:34 -070047 static void drawNumber(float number, int left, SkColor, SkCanvas&);
48
49 const sp<GraphicBuffer> getOrCreateBuffers(float currentHdrSdrRatio);
50
Ady Abrahamddba9342023-10-02 16:28:03 -070051 float mCurrentHdrSdrRatio = 1.f;
Sally Qi147581b2023-06-27 11:55:34 -070052 const std::unique_ptr<SurfaceControlHolder> mSurfaceControl;
Sally Qi127d99c2023-07-26 20:31:44 +080053
54 size_t mIndex = 0;
55 std::array<sp<GraphicBuffer>, 2> mRingBuffer;
Sally Qi6f020402024-08-05 08:53:44 -070056
57 SurfaceComposerClient::Transaction createTransaction() const;
Sally Qi147581b2023-06-27 11:55:34 -070058};
59} // namespace android