• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 {
28 private:
29     // Effectively making the constructor private, while keeping std::make_unique work
30     struct ConstructorTag {};
31 
32 public:
33     static std::unique_ptr<HdrSdrRatioOverlay> create();
34 
35     void setLayerStack(ui::LayerStack);
36     void setViewport(ui::Size);
37     void animate();
38     void changeHdrSdrRatio(float currentRatio);
39 
40     HdrSdrRatioOverlay(ConstructorTag);
41 
42 private:
43     bool initCheck() const;
44 
45     static sp<GraphicBuffer> draw(float currentHdrSdrRatio, SkColor, ui::Transform::RotationFlags,
46                                   sp<GraphicBuffer>& ringBufer);
47     static void drawNumber(float number, int left, SkColor, SkCanvas&);
48 
49     const sp<GraphicBuffer> getOrCreateBuffers(float currentHdrSdrRatio);
50 
51     float mCurrentHdrSdrRatio = 1.f;
52     const std::unique_ptr<SurfaceControlHolder> mSurfaceControl;
53 
54     size_t mIndex = 0;
55     std::array<sp<GraphicBuffer>, 2> mRingBuffer;
56 };
57 } // namespace android
58