2
2
* Copyright © 2013 Canonical Ltd.
4
4
* This program is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 3 as
5
* it under the terms of the GNU Lesser General Public License version 3 as
6
6
* published by the Free Software Foundation.
8
8
* This program is distributed in the hope that it will be useful,
9
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
11
* GNU Lesser General Public License for more details.
13
* You should have received a copy of the GNU General Public License
13
* You should have received a copy of the GNU Lesser General Public License
14
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
* Authored by: Kevin DuBois <kevin.dubois@canonical.com>
30
30
namespace mga=mg::android;
31
31
namespace geom=mir::geometry;
33
mga::InternalClientWindow::InternalClientWindow(std::shared_ptr<InternalSurface> const& surface,
34
std::shared_ptr<InterpreterResourceCache> const& cache)
33
mga::InternalClientWindow::InternalClientWindow(std::shared_ptr<InternalSurface> const& surface)
35
34
: surface(surface),
38
format = mga::to_android_format(geometry::PixelFormat(surface->pixel_format()));
37
format = mga::to_android_format(MirPixelFormat(surface->pixel_format()));
41
40
mg::NativeBuffer* mga::InternalClientWindow::driver_requests_buffer()
43
auto buffer = surface->advance_client_buffer();
44
surface->swap_buffers(buffer);
44
47
auto handle = buffer->native_buffer_handle();
45
resource_cache->store_buffer(buffer, handle);
48
lookup[handle->anwb()] = {buffer, handle};
46
52
return handle.get();
49
void mga::InternalClientWindow::driver_returns_buffer(ANativeWindowBuffer* buffer, int fence_fd)
55
void mga::InternalClientWindow::driver_returns_buffer(ANativeWindowBuffer* key, int fence_fd)
51
resource_cache->update_native_fence(buffer, fence_fd);
52
resource_cache->retrieve_buffer(buffer);
53
/* here, the mc::TemporaryBuffer will destruct, triggering buffer advance */
57
auto it = lookup.find(key);
58
if (it == lookup.end())
60
BOOST_THROW_EXCEPTION(std::runtime_error("driver is returning buffers it never was given!"));
63
auto handle = it->second.handle;
64
buffer = it->second.buffer;
67
handle->update_fence(fence_fd);
68
surface->swap_buffers(buffer);
56
71
void mga::InternalClientWindow::dispatch_driver_request_format(int request_format)