Index: ui/ozone/platform/dri/native_window_manager.cc |
diff --git a/ui/ozone/platform/dri/native_window_manager.cc b/ui/ozone/platform/dri/native_window_manager.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..4364b21ec293336a9eaf614d94d7f3609a9f3f3b |
--- /dev/null |
+++ b/ui/ozone/platform/dri/native_window_manager.cc |
@@ -0,0 +1,53 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "ui/ozone/platform/dri/native_window_manager.h" |
+ |
+namespace ui { |
+ |
+NativeWindowManager::NativeWindowManager() : allocated_widgets_(0) { |
+} |
+ |
+NativeWindowManager::~NativeWindowManager() { |
+} |
+ |
+gfx::AcceleratedWidget NativeWindowManager::AllocateAcceleratedWidget() { |
+ // We're not using 0 since other code assumes that a 0 AcceleratedWidget is an |
+ // invalid widget. |
+ return ++allocated_widgets_; |
+} |
+ |
+void NativeWindowManager::AddNativeWindowDelegate( |
+ gfx::AcceleratedWidget widget, |
+ NativeWindowDelegate* delegate) { |
+ DCHECK(delegate_map_.find(widget) == delegate_map_.end()) |
+ << "Surface delegate already added."; |
spang
2014/08/18 19:31:30
surface delegate?
|
+ delegate_map_.insert(std::make_pair(widget, delegate)); |
+} |
+ |
+void NativeWindowManager::RemoveNativeWindowDelegate( |
+ gfx::AcceleratedWidget widget) { |
+ WidgetToDelegateMap::iterator it = delegate_map_.find(widget); |
+ DCHECK(it != delegate_map_.end()) |
+ << "Attempting to remove non-existing delegate."; |
+ |
+ delegate_map_.erase(it); |
+} |
+ |
+NativeWindowDelegate* NativeWindowManager::GetNativeWindowDelegate( |
+ gfx::AcceleratedWidget widget) { |
+ WidgetToDelegateMap::iterator it = delegate_map_.find(widget); |
+ if (it != delegate_map_.end()) |
+ return it->second; |
+ |
+ NOTREACHED(); |
+ return NULL; |
+} |
+ |
+bool NativeWindowManager::HasNativeWindowDelegate( |
+ gfx::AcceleratedWidget widget) { |
+ return delegate_map_.find(widget) != delegate_map_.end(); |
+} |
+ |
+} // namespace ui |