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

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

Issue 106633002: GBM Ozone implementation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 6 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/ozone/platform/dri/screen_manager.h" 5 #include "ui/ozone/platform/dri/screen_manager.h"
6 6
7 #include <xf86drmMode.h> 7 #include <xf86drmMode.h>
8 8
9 #include "ui/gfx/geometry/point.h" 9 #include "ui/gfx/geometry/point.h"
10 #include "ui/gfx/geometry/rect.h" 10 #include "ui/gfx/geometry/rect.h"
11 #include "ui/gfx/geometry/size.h" 11 #include "ui/gfx/geometry/size.h"
12 #include "ui/ozone/platform/dri/dri_surface.h"
13 #include "ui/ozone/platform/dri/dri_util.h" 12 #include "ui/ozone/platform/dri/dri_util.h"
14 #include "ui/ozone/platform/dri/hardware_display_controller.h" 13 #include "ui/ozone/platform/dri/hardware_display_controller.h"
14 #include "ui/ozone/platform/dri/scanout_surface.h"
15 15
16 namespace ui { 16 namespace ui {
17 17
18 ScreenManager::ScreenManager(DriWrapper* dri) 18 ScreenManager::ScreenManager(
19 : dri_(dri), last_added_widget_(0) { 19 DriWrapper* dri, ScanoutSurfaceGenerator* surface_generator)
20 : dri_(dri), surface_generator_(surface_generator), last_added_widget_(0) {
20 } 21 }
21 22
22 ScreenManager::~ScreenManager() { 23 ScreenManager::~ScreenManager() {
23 } 24 }
24 25
25 void ScreenManager::RemoveDisplayController(uint32_t crtc, uint32_t connector) { 26 void ScreenManager::RemoveDisplayController(uint32_t crtc, uint32_t connector) {
26 HardwareDisplayControllerMap::iterator it = 27 HardwareDisplayControllerMap::iterator it =
27 FindDisplayController(crtc, connector); 28 FindDisplayController(crtc, connector);
28 if (it != controllers_.end()) { 29 if (it != controllers_.end()) {
29 delete it->second; 30 delete it->second;
(...skipping 14 matching lines...) Expand all
44 controller = it->second; 45 controller = it->second;
45 controller->UnbindSurfaceFromController(); 46 controller->UnbindSurfaceFromController();
46 } 47 }
47 48
48 if (it == controllers_.end()) { 49 if (it == controllers_.end()) {
49 controller = new HardwareDisplayController(dri_, connector, crtc); 50 controller = new HardwareDisplayController(dri_, connector, crtc);
50 controllers_.insert(std::make_pair(++last_added_widget_, controller)); 51 controllers_.insert(std::make_pair(++last_added_widget_, controller));
51 } 52 }
52 53
53 // Create a surface suitable for the current controller. 54 // Create a surface suitable for the current controller.
54 scoped_ptr<DriSurface> surface( 55 scoped_ptr<ScanoutSurface> surface(
55 CreateSurface(gfx::Size(mode.hdisplay, mode.vdisplay))); 56 surface_generator_->Create(gfx::Size(mode.hdisplay, mode.vdisplay)));
56 57
57 if (!surface->Initialize()) { 58 if (!surface->Initialize()) {
58 LOG(ERROR) << "Failed to initialize surface"; 59 LOG(ERROR) << "Failed to initialize surface";
59 return false; 60 return false;
60 } 61 }
61 62
62 // Bind the surface to the controller. This will register the backing buffers 63 // Bind the surface to the controller. This will register the backing buffers
63 // with the hardware CRTC such that we can show the buffers and performs the 64 // with the hardware CRTC such that we can show the buffers and performs the
64 // initial modeset. The controller takes ownership of the surface. 65 // initial modeset. The controller takes ownership of the surface.
65 if (!controller->BindSurfaceToController(surface.Pass(), mode)) { 66 if (!controller->BindSurfaceToController(surface.Pass(), mode)) {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 if (dpms) 125 if (dpms)
125 dri_->SetProperty(displays[0]->connector()->connector_id, 126 dri_->SetProperty(displays[0]->connector()->connector_id,
126 dpms->prop_id, 127 dpms->prop_id,
127 DRM_MODE_DPMS_ON); 128 DRM_MODE_DPMS_ON);
128 129
129 ConfigureDisplayController(displays[0]->crtc()->crtc_id, 130 ConfigureDisplayController(displays[0]->crtc()->crtc_id,
130 displays[0]->connector()->connector_id, 131 displays[0]->connector()->connector_id,
131 displays[0]->connector()->modes[0]); 132 displays[0]->connector()->modes[0]);
132 } 133 }
133 134
134 DriSurface* ScreenManager::CreateSurface(const gfx::Size& size) {
135 return new DriSurface(dri_, size);
136 }
137
138 } // namespace ui 135 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/dri/screen_manager.h ('k') | ui/ozone/platform/dri/screen_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698