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

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

Issue 469343003: [Ozone-GBM] Pumb DriWindowDelegate throughout the platform (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 6 years, 4 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/dri_surface_factory.h" 5 #include "ui/ozone/platform/dri/dri_surface_factory.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "third_party/skia/include/core/SkBitmap.h" 10 #include "third_party/skia/include/core/SkBitmap.h"
11 #include "third_party/skia/include/core/SkDevice.h" 11 #include "third_party/skia/include/core/SkDevice.h"
12 #include "third_party/skia/include/core/SkSurface.h" 12 #include "third_party/skia/include/core/SkSurface.h"
13 #include "ui/gfx/native_widget_types.h" 13 #include "ui/gfx/native_widget_types.h"
14 #include "ui/ozone/platform/dri/dri_buffer.h" 14 #include "ui/ozone/platform/dri/dri_buffer.h"
15 #include "ui/ozone/platform/dri/dri_surface.h" 15 #include "ui/ozone/platform/dri/dri_surface.h"
16 #include "ui/ozone/platform/dri/dri_util.h" 16 #include "ui/ozone/platform/dri/dri_util.h"
17 #include "ui/ozone/platform/dri/dri_window_delegate_impl.h"
18 #include "ui/ozone/platform/dri/dri_window_manager.h"
17 #include "ui/ozone/platform/dri/dri_wrapper.h" 19 #include "ui/ozone/platform/dri/dri_wrapper.h"
18 #include "ui/ozone/platform/dri/hardware_display_controller.h" 20 #include "ui/ozone/platform/dri/hardware_display_controller.h"
19 #include "ui/ozone/platform/dri/screen_manager.h" 21 #include "ui/ozone/platform/dri/screen_manager.h"
20 #include "ui/ozone/public/surface_ozone_canvas.h" 22 #include "ui/ozone/public/surface_ozone_canvas.h"
21 23
22 namespace ui { 24 namespace ui {
23 25
24 namespace { 26 namespace {
25 27
26 // TODO(dnicoara) Read the cursor plane size from the hardware. 28 // TODO(dnicoara) Read the cursor plane size from the hardware.
(...skipping 12 matching lines...) Expand all
39 0, 0, canvas->getDeviceSize().width(), canvas->getDeviceSize().height()); 41 0, 0, canvas->getDeviceSize().width(), canvas->getDeviceSize().height());
40 canvas->clipRect(clip, SkRegion::kReplace_Op); 42 canvas->clipRect(clip, SkRegion::kReplace_Op);
41 canvas->drawBitmapRectToRect(image, &damage, damage); 43 canvas->drawBitmapRectToRect(image, &damage, damage);
42 } 44 }
43 45
44 } // namespace 46 } // namespace
45 47
46 // static 48 // static
47 const gfx::AcceleratedWidget DriSurfaceFactory::kDefaultWidgetHandle = 1; 49 const gfx::AcceleratedWidget DriSurfaceFactory::kDefaultWidgetHandle = 1;
48 50
49 DriSurfaceFactory::DriSurfaceFactory( 51 DriSurfaceFactory::DriSurfaceFactory(DriWrapper* drm,
50 DriWrapper* drm, 52 ScreenManager* screen_manager,
51 ScreenManager* screen_manager) 53 DriWindowManager* window_manager)
52 : drm_(drm), 54 : drm_(drm),
53 screen_manager_(screen_manager), 55 screen_manager_(screen_manager),
56 window_manager_(window_manager),
54 state_(UNINITIALIZED), 57 state_(UNINITIALIZED),
55 allocated_widgets_(0),
56 cursor_frontbuffer_(0) { 58 cursor_frontbuffer_(0) {
57 } 59 }
58 60
59 DriSurfaceFactory::~DriSurfaceFactory() { 61 DriSurfaceFactory::~DriSurfaceFactory() {
60 if (state_ == INITIALIZED) 62 if (state_ == INITIALIZED)
61 ShutdownHardware(); 63 ShutdownHardware();
62 } 64 }
63 65
64 DriSurfaceFactory::HardwareState DriSurfaceFactory::InitializeHardware() { 66 DriSurfaceFactory::HardwareState DriSurfaceFactory::InitializeHardware() {
65 if (state_ != UNINITIALIZED) 67 if (state_ != UNINITIALIZED)
(...skipping 19 matching lines...) Expand all
85 state_ = INITIALIZED; 87 state_ = INITIALIZED;
86 return state_; 88 return state_;
87 } 89 }
88 90
89 void DriSurfaceFactory::ShutdownHardware() { 91 void DriSurfaceFactory::ShutdownHardware() {
90 DCHECK(state_ == INITIALIZED); 92 DCHECK(state_ == INITIALIZED);
91 state_ = UNINITIALIZED; 93 state_ = UNINITIALIZED;
92 } 94 }
93 95
94 scoped_ptr<ui::SurfaceOzoneCanvas> DriSurfaceFactory::CreateCanvasForWidget( 96 scoped_ptr<ui::SurfaceOzoneCanvas> DriSurfaceFactory::CreateCanvasForWidget(
95 gfx::AcceleratedWidget w) { 97 gfx::AcceleratedWidget widget) {
96 DCHECK(state_ == INITIALIZED); 98 DCHECK(state_ == INITIALIZED);
97 // Initial cursor set. 99 // Initial cursor set.
98 ResetCursor(w); 100 ResetCursor(widget);
99 101
100 return scoped_ptr<ui::SurfaceOzoneCanvas>( 102 return scoped_ptr<ui::SurfaceOzoneCanvas>(
101 new DriSurface(drm_, screen_manager_->GetDisplayController(w))); 103 new DriSurface(window_manager_->GetWindowDelegate(widget), drm_));
102 } 104 }
103 105
104 bool DriSurfaceFactory::LoadEGLGLES2Bindings( 106 bool DriSurfaceFactory::LoadEGLGLES2Bindings(
105 AddGLLibraryCallback add_gl_library, 107 AddGLLibraryCallback add_gl_library,
106 SetGLGetProcAddressProcCallback set_gl_get_proc_address) { 108 SetGLGetProcAddressProcCallback set_gl_get_proc_address) {
107 return false; 109 return false;
108 } 110 }
109 111
110 gfx::AcceleratedWidget DriSurfaceFactory::GetAcceleratedWidget() { 112 void DriSurfaceFactory::SetHardwareCursor(gfx::AcceleratedWidget widget,
111 DCHECK(state_ != FAILED);
112
113 // We're not using 0 since other code assumes that a 0 AcceleratedWidget is an
114 // invalid widget.
115 return ++allocated_widgets_;
116 }
117
118 gfx::Size DriSurfaceFactory::GetWidgetSize(gfx::AcceleratedWidget w) {
119 base::WeakPtr<HardwareDisplayController> controller =
120 screen_manager_->GetDisplayController(w);
121 if (controller)
122 return gfx::Size(controller->get_mode().hdisplay,
123 controller->get_mode().vdisplay);
124
125 return gfx::Size(0, 0);
126 }
127
128 void DriSurfaceFactory::SetHardwareCursor(gfx::AcceleratedWidget window,
129 const SkBitmap& image, 113 const SkBitmap& image,
130 const gfx::Point& location) { 114 const gfx::Point& location) {
131 cursor_bitmap_ = image; 115 cursor_bitmap_ = image;
132 cursor_location_ = location; 116 cursor_location_ = location;
133 117
134 if (state_ != INITIALIZED) 118 if (state_ != INITIALIZED)
135 return; 119 return;
136 120
137 ResetCursor(window); 121 ResetCursor(widget);
138 } 122 }
139 123
140 void DriSurfaceFactory::MoveHardwareCursor(gfx::AcceleratedWidget window, 124 void DriSurfaceFactory::MoveHardwareCursor(gfx::AcceleratedWidget widget,
141 const gfx::Point& location) { 125 const gfx::Point& location) {
142 cursor_location_ = location; 126 cursor_location_ = location;
143 127
144 if (state_ != INITIALIZED) 128 if (state_ != INITIALIZED)
145 return; 129 return;
146 130
147 base::WeakPtr<HardwareDisplayController> controller = 131 HardwareDisplayController* controller =
148 screen_manager_->GetDisplayController(window); 132 window_manager_->GetWindowDelegate(widget)->GetController();
149 if (controller) 133 if (controller)
150 controller->MoveCursor(location); 134 controller->MoveCursor(location);
151 } 135 }
152 136
153 //////////////////////////////////////////////////////////////////////////////// 137 ////////////////////////////////////////////////////////////////////////////////
154 // DriSurfaceFactory private 138 // DriSurfaceFactory private
155 139
156 void DriSurfaceFactory::ResetCursor(gfx::AcceleratedWidget w) { 140 void DriSurfaceFactory::ResetCursor(gfx::AcceleratedWidget widget) {
157 base::WeakPtr<HardwareDisplayController> controller = 141 HardwareDisplayController* controller =
158 screen_manager_->GetDisplayController(w); 142 window_manager_->GetWindowDelegate(widget)->GetController();
159 143
160 if (!cursor_bitmap_.empty()) { 144 if (!cursor_bitmap_.empty()) {
161 // Draw new cursor into backbuffer. 145 // Draw new cursor into backbuffer.
162 UpdateCursorImage(cursor_buffers_[cursor_frontbuffer_ ^ 1].get(), 146 UpdateCursorImage(cursor_buffers_[cursor_frontbuffer_ ^ 1].get(),
163 cursor_bitmap_); 147 cursor_bitmap_);
164 148
165 // Reset location & buffer. 149 // Reset location & buffer.
166 if (controller) { 150 if (controller) {
167 controller->MoveCursor(cursor_location_); 151 controller->MoveCursor(cursor_location_);
168 controller->SetCursor(cursor_buffers_[cursor_frontbuffer_ ^ 1]); 152 controller->SetCursor(cursor_buffers_[cursor_frontbuffer_ ^ 1]);
169 cursor_frontbuffer_ ^= 1; 153 cursor_frontbuffer_ ^= 1;
170 } 154 }
171 } else { 155 } else {
172 // No cursor set. 156 // No cursor set.
173 if (controller) 157 if (controller)
174 controller->UnsetCursor(); 158 controller->UnsetCursor();
175 } 159 }
176 } 160 }
177 161
178 } // namespace ui 162 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698