OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/gfx/ozone/dri/dri_surface_factory.h" | 5 #include "ui/gfx/ozone/dri/dri_surface_factory.h" |
6 | 6 |
7 #include <drm.h> | 7 #include <drm.h> |
8 #include <errno.h> | 8 #include <errno.h> |
9 #include <xf86drm.h> | 9 #include <xf86drm.h> |
10 | 10 |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
204 } | 204 } |
205 | 205 |
206 // Bind the surface to the controller. This will register the backing buffers | 206 // Bind the surface to the controller. This will register the backing buffers |
207 // with the hardware CRTC such that we can show the buffers. The controller | 207 // with the hardware CRTC such that we can show the buffers. The controller |
208 // takes ownership of the surface. | 208 // takes ownership of the surface. |
209 if (!controller_->BindSurfaceToController(surface.Pass())) { | 209 if (!controller_->BindSurfaceToController(surface.Pass())) { |
210 LOG(ERROR) << "Failed to bind surface to controller"; | 210 LOG(ERROR) << "Failed to bind surface to controller"; |
211 return gfx::kNullAcceleratedWidget; | 211 return gfx::kNullAcceleratedWidget; |
212 } | 212 } |
213 | 213 |
214 // Initial cursor set. | |
215 ResetCursor(); | |
216 | |
214 return reinterpret_cast<gfx::AcceleratedWidget>(controller_->get_surface()); | 217 return reinterpret_cast<gfx::AcceleratedWidget>(controller_->get_surface()); |
215 } | 218 } |
216 | 219 |
217 bool DriSurfaceFactory::LoadEGLGLES2Bindings( | 220 bool DriSurfaceFactory::LoadEGLGLES2Bindings( |
218 AddGLLibraryCallback add_gl_library, | 221 AddGLLibraryCallback add_gl_library, |
219 SetGLGetProcAddressProcCallback set_gl_get_proc_address) { | 222 SetGLGetProcAddressProcCallback set_gl_get_proc_address) { |
220 return false; | 223 return false; |
221 } | 224 } |
222 | 225 |
223 bool DriSurfaceFactory::AttemptToResizeAcceleratedWidget( | 226 bool DriSurfaceFactory::AttemptToResizeAcceleratedWidget( |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
266 | 269 |
267 scoped_ptr<gfx::VSyncProvider> DriSurfaceFactory::CreateVSyncProvider( | 270 scoped_ptr<gfx::VSyncProvider> DriSurfaceFactory::CreateVSyncProvider( |
268 gfx::AcceleratedWidget w) { | 271 gfx::AcceleratedWidget w) { |
269 CHECK(state_ == INITIALIZED); | 272 CHECK(state_ == INITIALIZED); |
270 return scoped_ptr<VSyncProvider>(new DriVSyncProvider(controller_.get())); | 273 return scoped_ptr<VSyncProvider>(new DriVSyncProvider(controller_.get())); |
271 } | 274 } |
272 | 275 |
273 void DriSurfaceFactory::SetHardwareCursor(gfx::AcceleratedWidget window, | 276 void DriSurfaceFactory::SetHardwareCursor(gfx::AcceleratedWidget window, |
274 const SkBitmap& image, | 277 const SkBitmap& image, |
275 const gfx::Point& location) { | 278 const gfx::Point& location) { |
279 cursor_bitmap_ = image; | |
280 cursor_location_ = location; | |
281 | |
276 if (state_ != INITIALIZED) | 282 if (state_ != INITIALIZED) |
277 return; | 283 return; |
278 | 284 |
279 UpdateCursorImage(cursor_surface_.get(), image); | 285 ResetCursor(); |
280 controller_->MoveCursor(location); | |
281 controller_->SetCursor(*cursor_surface_.get()); | |
282 cursor_surface_->SwapBuffers(); | |
283 } | 286 } |
284 | 287 |
285 void DriSurfaceFactory::MoveHardwareCursor(gfx::AcceleratedWidget window, | 288 void DriSurfaceFactory::MoveHardwareCursor(gfx::AcceleratedWidget window, |
286 const gfx::Point& location) { | 289 const gfx::Point& location) { |
290 cursor_location_ = location; | |
291 | |
287 if (state_ != INITIALIZED) | 292 if (state_ != INITIALIZED) |
288 return; | 293 return; |
289 | 294 |
290 controller_->MoveCursor(location); | 295 controller_->MoveCursor(location); |
291 } | 296 } |
292 | 297 |
293 void DriSurfaceFactory::UnsetHardwareCursor(gfx::AcceleratedWidget window) { | 298 void DriSurfaceFactory::UnsetHardwareCursor(gfx::AcceleratedWidget window) { |
299 cursor_bitmap_.reset(); | |
300 | |
294 if (state_ != INITIALIZED) | 301 if (state_ != INITIALIZED) |
295 return; | 302 return; |
296 | 303 |
297 controller_->UnsetCursor(); | 304 ResetCursor(); |
298 } | 305 } |
299 | 306 |
300 //////////////////////////////////////////////////////////////////////////////// | 307 //////////////////////////////////////////////////////////////////////////////// |
301 // DriSurfaceFactory private | 308 // DriSurfaceFactory private |
302 | 309 |
303 DriSurface* DriSurfaceFactory::CreateSurface(const gfx::Size& size) { | 310 DriSurface* DriSurfaceFactory::CreateSurface(const gfx::Size& size) { |
304 return new DriSurface(drm_.get(), size); | 311 return new DriSurface(drm_.get(), size); |
305 } | 312 } |
306 | 313 |
307 DriWrapper* DriSurfaceFactory::CreateWrapper() { | 314 DriWrapper* DriSurfaceFactory::CreateWrapper() { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
360 void DriSurfaceFactory::WaitForPageFlipEvent(int fd) { | 367 void DriSurfaceFactory::WaitForPageFlipEvent(int fd) { |
361 drmEventContext drm_event; | 368 drmEventContext drm_event; |
362 drm_event.version = DRM_EVENT_CONTEXT_VERSION; | 369 drm_event.version = DRM_EVENT_CONTEXT_VERSION; |
363 drm_event.page_flip_handler = HandlePageFlipEvent; | 370 drm_event.page_flip_handler = HandlePageFlipEvent; |
364 drm_event.vblank_handler = NULL; | 371 drm_event.vblank_handler = NULL; |
365 | 372 |
366 // Wait for the page-flip to complete. | 373 // Wait for the page-flip to complete. |
367 drmHandleEvent(fd, &drm_event); | 374 drmHandleEvent(fd, &drm_event); |
368 } | 375 } |
369 | 376 |
377 void DriSurfaceFactory::ResetCursor() { | |
378 if (!cursor_bitmap_.empty()) { | |
379 // Draw new cursor into backbuffer. | |
380 UpdateCursorImage(cursor_surface_.get(), cursor_bitmap_); | |
381 cursor_surface_->SwapBuffers(); | |
dnicoara
2014/03/21 21:38:35
Could we move this inside HardwareDisplayControlle
spang
2014/03/26 22:26:35
Done.
| |
382 | |
383 // Reset location & buffer. | |
384 controller_->MoveCursor(cursor_location_); | |
385 controller_->SetCursor(*cursor_surface_.get()); | |
386 } else { | |
387 // No cursor set. | |
388 controller_->UnsetCursor(); | |
389 } | |
390 } | |
391 | |
392 | |
370 } // namespace gfx | 393 } // namespace gfx |
OLD | NEW |