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

Side by Side Diff: ui/ozone/platform/drm/host/drm_window_host_manager.cc

Issue 1285183008: Ozone integration. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: add missing license header Created 5 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
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/drm/host/drm_window_host_manager.h"
6
7 #include "base/logging.h"
8 #include "ui/ozone/platform/drm/host/drm_window_host.h"
9
10 namespace ui {
11
12 DrmWindowHostManager::DrmWindowHostManager() {
13 }
14
15 DrmWindowHostManager::~DrmWindowHostManager() {
16 }
17
18 gfx::AcceleratedWidget DrmWindowHostManager::NextAcceleratedWidget() {
19 // We're not using 0 since other code assumes that a 0 AcceleratedWidget is an
20 // invalid widget.
21 return ++last_allocated_widget_;
22 }
23
24 void DrmWindowHostManager::AddWindow(gfx::AcceleratedWidget widget,
25 DrmWindowHost* window) {
26 std::pair<WidgetToWindowMap::iterator, bool> result = window_map_.insert(
27 std::pair<gfx::AcceleratedWidget, DrmWindowHost*>(widget, window));
28 DCHECK(result.second) << "Window for " << widget << " already added.";
29 }
30
31 void DrmWindowHostManager::RemoveWindow(gfx::AcceleratedWidget widget) {
32 WidgetToWindowMap::iterator it = window_map_.find(widget);
33 if (it != window_map_.end())
34 window_map_.erase(it);
35 else
36 NOTREACHED() << "Attempting to remove non-existing window " << widget;
37
38 if (event_grabber_ == widget)
39 event_grabber_ = gfx::kNullAcceleratedWidget;
40 }
41
42 DrmWindowHost* DrmWindowHostManager::GetWindow(gfx::AcceleratedWidget widget) {
43 WidgetToWindowMap::iterator it = window_map_.find(widget);
44 if (it != window_map_.end())
45 return it->second;
46
47 NOTREACHED() << "Attempting to get non-existing window " << widget;
48 return NULL;
49 }
50
51 DrmWindowHost* DrmWindowHostManager::GetWindowAt(const gfx::Point& location) {
52 for (auto it = window_map_.begin(); it != window_map_.end(); ++it)
53 if (it->second->GetBounds().Contains(location))
54 return it->second;
55
56 return NULL;
57 }
58
59 DrmWindowHost* DrmWindowHostManager::GetPrimaryWindow() {
60 auto it = window_map_.begin();
61 return it != window_map_.end() ? it->second : nullptr;
62 }
63
64 void DrmWindowHostManager::GrabEvents(gfx::AcceleratedWidget widget) {
65 if (event_grabber_ != gfx::kNullAcceleratedWidget)
66 return;
67 event_grabber_ = widget;
68 }
69
70 void DrmWindowHostManager::UngrabEvents(gfx::AcceleratedWidget widget) {
71 if (event_grabber_ != widget)
72 return;
73 event_grabber_ = gfx::kNullAcceleratedWidget;
74 }
75
76 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/drm/host/drm_window_host_manager.h ('k') | ui/ozone/platform/drm/ozone_platform_drm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698