OSDN Git Service

Move all display transform checks to PlaneState.
[android-x86/external-IA-Hardware-Composer.git] / common / compositor / compositor.h
1 /*
2 // Copyright (c) 2016 Intel Corporation
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 #ifndef COMMON_COMPOSITOR_COMPOSITOR_H_
18 #define COMMON_COMPOSITOR_COMPOSITOR_H_
19
20 #include <platformdefines.h>
21
22 #include <memory>
23 #include <vector>
24
25 #include "compositionregion.h"
26 #include "displayplanestate.h"
27 #include "renderstate.h"
28 #include "compositorthread.h"
29 #include "factory.h"
30
31 namespace hwcomposer {
32
33 class DisplayPlaneManager;
34 class ResourceManager;
35 struct OverlayLayer;
36
37 class Compositor {
38  public:
39   Compositor();
40   ~Compositor();
41
42   void Init(ResourceManager *buffer_manager, uint32_t gpu_fd);
43   void Reset();
44
45   Compositor(const Compositor &) = delete;
46
47   bool BeginFrame(bool disable_explicit_sync);
48   bool Draw(DisplayPlaneStateList &planes, std::vector<OverlayLayer> &layers,
49             const std::vector<HwcRect<int>> &display_frame);
50   bool DrawOffscreen(std::vector<OverlayLayer> &layers,
51                      const std::vector<HwcRect<int>> &display_frame,
52                      const std::vector<size_t> &source_layers,
53                      ResourceManager *resource_manager, uint32_t width,
54                      uint32_t height, HWCNativeHandle output_handle,
55                      int32_t acquire_fence, int32_t *retire_fence);
56   void FreeResources();
57
58   void SetVideoColor(HWCColorControl color, float value);
59   void GetVideoColor(HWCColorControl color, float *value, float *start,
60                      float *end);
61   void RestoreVideoDefaultColor(HWCColorControl color);
62
63  private:
64   bool CalculateRenderState(std::vector<OverlayLayer> &layers,
65                             const std::vector<CompositionRegion> &comp_regions,
66                             DrawState &state, bool uses_display_up_scaling,
67                             bool use_plane_transform = false);
68   void SeparateLayers(const std::vector<size_t> &dedicated_layers,
69                       const std::vector<size_t> &source_layers,
70                       const std::vector<HwcRect<int>> &display_frame,
71                       const HwcRect<int> &damage_region,
72                       std::vector<CompositionRegion> &comp_regions);
73
74   std::unique_ptr<CompositorThread> thread_;
75   SpinLock lock_;
76   HWCColorMap colors_;
77 };
78
79 }  // namespace hwcomposer
80 #endif  // COMMON_COMPOSITOR_COMPOSITOR_H_