OLD | NEW |
(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/dri/native_window_manager.h" |
| 6 |
| 7 namespace ui { |
| 8 |
| 9 NativeWindowManager::NativeWindowManager() : allocated_widgets_(0) { |
| 10 } |
| 11 |
| 12 NativeWindowManager::~NativeWindowManager() { |
| 13 } |
| 14 |
| 15 gfx::AcceleratedWidget NativeWindowManager::AllocateAcceleratedWidget() { |
| 16 // We're not using 0 since other code assumes that a 0 AcceleratedWidget is an |
| 17 // invalid widget. |
| 18 return ++allocated_widgets_; |
| 19 } |
| 20 |
| 21 void NativeWindowManager::AddNativeWindowDelegate( |
| 22 gfx::AcceleratedWidget widget, |
| 23 NativeWindowDelegate* delegate) { |
| 24 DCHECK(delegate_map_.find(widget) == delegate_map_.end()) |
| 25 << "Surface delegate already added."; |
| 26 delegate_map_.insert(std::make_pair(widget, delegate)); |
| 27 } |
| 28 |
| 29 void NativeWindowManager::RemoveNativeWindowDelegate( |
| 30 gfx::AcceleratedWidget widget) { |
| 31 std::map<gfx::AcceleratedWidget, NativeWindowDelegate*>::iterator it = |
| 32 delegate_map_.find(widget); |
| 33 DCHECK(it != delegate_map_.end()) |
| 34 << "Attempting to remove non-existing delegate."; |
| 35 |
| 36 delegate_map_.erase(it); |
| 37 } |
| 38 |
| 39 NativeWindowDelegate* NativeWindowManager::GetNativeWindowDelegate( |
| 40 gfx::AcceleratedWidget widget) { |
| 41 std::map<gfx::AcceleratedWidget, NativeWindowDelegate*>::iterator it = |
| 42 delegate_map_.find(widget); |
| 43 if (it != delegate_map_.end()) |
| 44 return it->second; |
| 45 |
| 46 NOTREACHED(); |
| 47 return NULL; |
| 48 } |
| 49 |
| 50 bool NativeWindowManager::HasNativeWindowDelegate( |
| 51 gfx::AcceleratedWidget widget) { |
| 52 return delegate_map_.find(widget) != delegate_map_.end(); |
| 53 } |
| 54 |
| 55 } // namespace ui |
OLD | NEW |