| 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..ae32d227ade25562ff619675fceeb876d5738078
|
| --- /dev/null
|
| +++ b/ui/ozone/platform/dri/native_window_manager.cc
|
| @@ -0,0 +1,55 @@
|
| +// 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.";
|
| + delegate_map_.insert(std::make_pair(widget, delegate));
|
| +}
|
| +
|
| +void NativeWindowManager::RemoveNativeWindowDelegate(
|
| + gfx::AcceleratedWidget widget) {
|
| + std::map<gfx::AcceleratedWidget, NativeWindowDelegate*>::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) {
|
| + std::map<gfx::AcceleratedWidget, NativeWindowDelegate*>::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
|
|
|