1 /*
2  * Copyright (C) 2016 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 <vector>
20 
21 #include <hardware/gralloc.h>
22 
23 #include "guest/hals/hwcomposer/common/base_composer.h"
24 #include "guest/hals/hwcomposer/common/hwcomposer.h"
25 
26 namespace cvd {
27 
28 class CpuComposer : public BaseComposer {
29  public:
30   CpuComposer(std::unique_ptr<ScreenView> screen_view);
31   virtual ~CpuComposer() = default;
32 
33   // override
34   int PrepareLayers(size_t num_layers, hwc_layer_1_t* layers) override;
35   // override
36   int SetLayers(size_t num_layers, hwc_layer_1_t* layers) override;
37 
38  protected:
39   static const int kNumTmpBufferPieces;
40   uint8_t* RotateTmpBuffer(unsigned int order);
41   uint8_t* GetSpecialTmpBuffer(size_t needed_size);
42   bool CanCompositeLayer(const hwc_layer_1_t& layer);
43   void CompositeLayer(hwc_layer_1_t* src_layer, int32_t fb_offset);
44   std::vector<uint8_t> tmp_buffer_;
45   std::vector<uint8_t> special_tmp_buffer_;
46 };
47 
48 }  // namespace cvd
49