• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (C) 2018 The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 #pragma once
15 
16 #include "AndroidWindow.h"
17 
18 #include <hardware/gralloc.h>
19 #include <system/window.h>
20 
21 namespace aemu {
22 
23 // Mostly a container class that takes the information
24 // from an existing Android window and native buffer.
25 class AndroidWindowBuffer : public ANativeWindowBuffer {
26 public:
27     // This does not refer directly to |window|
28     // after construction, merely using it
29     // to get information.
30     // Lifetime of this class versus |*buffer| is
31     // externally managed.
32     AndroidWindowBuffer(AndroidWindow* window,
33                         buffer_handle_t buffer,
34                         int usage = GRALLOC_USAGE_HW_RENDER,
35                         int format = HAL_PIXEL_FORMAT_RGBA_8888,
36                         int stride = 0);
37 
38     // Creating a buffer without needing a window.
39     AndroidWindowBuffer(int width, int height,
40                         buffer_handle_t buffer,
41                         int usage = GRALLOC_USAGE_HW_RENDER,
42                         int format = HAL_PIXEL_FORMAT_RGBA_8888,
43                         int stride = 0);
44 
45     ~AndroidWindowBuffer() = default;
46 };
47 
48 } // namespace aemu