• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 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.#pragma once
14 #pragma once
15 
16 #include <memory>
17 
18 class ANativeWindowBuffer;
19 
20 namespace aemu {
21 
22 class AndroidBufferQueue {
23 public:
24     static constexpr int kCapacity = 3;
25 
26     class Item {
27     public:
28         Item(ANativeWindowBuffer* buf = 0, int fd = -1) :
buffer(buf)29             buffer(buf), fenceFd(fd) { }
30         ANativeWindowBuffer* buffer = 0;
31         int fenceFd = -1;
32     };
33 
34     AndroidBufferQueue();
35     ~AndroidBufferQueue();
36 
37     void cancelBuffer(const Item& item);
38 
39     void queueBuffer(const Item& item);
40     void dequeueBuffer(Item* outItem);
41 
42     bool try_dequeueBuffer(Item* outItem);
43 
44 private:
45     class Impl;
46     std::unique_ptr<Impl> mImpl;
47 }; // namespace aemu
48 
49 } // namespace qemu