Sally Qi | 147581b | 2023-06-27 11:55:34 -0700 | [diff] [blame] | 1 | /** |
| 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 | |
| 24 | class SkCanvas; |
| 25 | |
| 26 | namespace android { |
| 27 | class HdrSdrRatioOverlay { |
Ady Abraham | ddba934 | 2023-10-02 16:28:03 -0700 | [diff] [blame] | 28 | private: |
| 29 | // Effectively making the constructor private, while keeping std::make_unique work |
| 30 | struct ConstructorTag {}; |
| 31 | |
Sally Qi | 147581b | 2023-06-27 11:55:34 -0700 | [diff] [blame] | 32 | public: |
Ady Abraham | ddba934 | 2023-10-02 16:28:03 -0700 | [diff] [blame] | 33 | static std::unique_ptr<HdrSdrRatioOverlay> create(); |
| 34 | |
Sally Qi | 147581b | 2023-06-27 11:55:34 -0700 | [diff] [blame] | 35 | void setLayerStack(ui::LayerStack); |
| 36 | void setViewport(ui::Size); |
| 37 | void animate(); |
| 38 | void changeHdrSdrRatio(float currentRatio); |
| 39 | |
Ady Abraham | ddba934 | 2023-10-02 16:28:03 -0700 | [diff] [blame] | 40 | HdrSdrRatioOverlay(ConstructorTag); |
| 41 | |
Sally Qi | 147581b | 2023-06-27 11:55:34 -0700 | [diff] [blame] | 42 | private: |
Ady Abraham | ddba934 | 2023-10-02 16:28:03 -0700 | [diff] [blame] | 43 | bool initCheck() const; |
Sally Qi | 147581b | 2023-06-27 11:55:34 -0700 | [diff] [blame] | 44 | |
Sally Qi | 127d99c | 2023-07-26 20:31:44 +0800 | [diff] [blame] | 45 | static sp<GraphicBuffer> draw(float currentHdrSdrRatio, SkColor, ui::Transform::RotationFlags, |
| 46 | sp<GraphicBuffer>& ringBufer); |
Sally Qi | 147581b | 2023-06-27 11:55:34 -0700 | [diff] [blame] | 47 | static void drawNumber(float number, int left, SkColor, SkCanvas&); |
| 48 | |
| 49 | const sp<GraphicBuffer> getOrCreateBuffers(float currentHdrSdrRatio); |
| 50 | |
Ady Abraham | ddba934 | 2023-10-02 16:28:03 -0700 | [diff] [blame] | 51 | float mCurrentHdrSdrRatio = 1.f; |
Sally Qi | 147581b | 2023-06-27 11:55:34 -0700 | [diff] [blame] | 52 | const std::unique_ptr<SurfaceControlHolder> mSurfaceControl; |
Sally Qi | 127d99c | 2023-07-26 20:31:44 +0800 | [diff] [blame] | 53 | |
| 54 | size_t mIndex = 0; |
| 55 | std::array<sp<GraphicBuffer>, 2> mRingBuffer; |
Sally Qi | 6f02040 | 2024-08-05 08:53:44 -0700 | [diff] [blame] | 56 | |
| 57 | SurfaceComposerClient::Transaction createTransaction() const; |
Sally Qi | 147581b | 2023-06-27 11:55:34 -0700 | [diff] [blame] | 58 | }; |
| 59 | } // namespace android |