Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(483)

Side by Side Diff: ui/ozone/platform/dri/buffer_data.cc

Issue 400283002: [Ozone-GBM] Migrate GBM buffers to use the ScanoutBuffer interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/ozone/platform/dri/buffer_data.h ('k') | ui/ozone/platform/dri/gbm.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/ozone/platform/dri/buffer_data.h"
6
7 #include <gbm.h>
8
9 #include "base/logging.h"
10 #include "ui/ozone/platform/dri/dri_wrapper.h"
11
12 namespace ui {
13
14 // Pixel configuration for the current buffer format.
15 // TODO(dnicoara) These will need to change once we query the hardware for
16 // supported configurations.
17 const uint8_t kColorDepth = 24;
18 const uint8_t kPixelDepth = 32;
19
20 BufferData::BufferData(DriWrapper* dri, gbm_bo* buffer)
21 : dri_(dri),
22 handle_(gbm_bo_get_handle(buffer).u32),
23 framebuffer_(0) {
24 // Register the buffer with the controller. This will allow us to scan out the
25 // buffer once we're done drawing into it. If we can't register the buffer
26 // then there's no point in having BufferData associated with it.
27 if (!dri_->AddFramebuffer(gbm_bo_get_width(buffer),
28 gbm_bo_get_height(buffer),
29 kColorDepth,
30 kPixelDepth,
31 gbm_bo_get_stride(buffer),
32 handle_,
33 &framebuffer_)) {
34 LOG(ERROR) << "Failed to register buffer";
35 }
36 }
37
38 BufferData::~BufferData() {
39 if (framebuffer_)
40 dri_->RemoveFramebuffer(framebuffer_);
41 }
42
43 // static
44 BufferData* BufferData::CreateData(DriWrapper* dri,
45 gbm_bo* buffer) {
46 BufferData* data = new BufferData(dri, buffer);
47 if (!data->framebuffer()) {
48 delete data;
49 return NULL;
50 }
51
52 // GBM can destroy the buffers at any time as long as they aren't locked. This
53 // sets a callback such that we can clean up all our state when GBM destroys
54 // the buffer.
55 gbm_bo_set_user_data(buffer, data, BufferData::Destroy);
56
57 return data;
58 }
59
60 // static
61 void BufferData::Destroy(gbm_bo* buffer, void* data) {
62 BufferData* bd = static_cast<BufferData*>(data);
63 delete bd;
64 }
65
66 // static
67 BufferData* BufferData::GetData(gbm_bo* buffer) {
68 return static_cast<BufferData*>(gbm_bo_get_user_data(buffer));
69 }
70
71 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/dri/buffer_data.h ('k') | ui/ozone/platform/dri/gbm.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698