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

Side by Side Diff: content/browser/renderer_host/accelerated_surface_container_manager_mac.cc

Issue 9958100: Unobfuscate RWHVMac accelerated compositing code path by separating it from plugin code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: public APIs of CompositingIOSurface set context current Created 8 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/renderer_host/accelerated_surface_container_manager_ma c.h" 5 #include "content/browser/renderer_host/accelerated_surface_container_manager_ma c.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "content/browser/renderer_host/accelerated_surface_container_mac.h" 8 #include "content/browser/renderer_host/accelerated_surface_container_mac.h"
9 #include "webkit/plugins/npapi/webplugin.h" 9 #include "webkit/plugins/npapi/webplugin.h"
10 #include "ui/gfx/rect.h" 10 #include "ui/gfx/rect.h"
11 11
12 AcceleratedSurfaceContainerManagerMac::AcceleratedSurfaceContainerManagerMac() 12 AcceleratedSurfaceContainerManagerMac::AcceleratedSurfaceContainerManagerMac()
13 : current_id_(0), 13 : current_id_(0) {
14 root_container_(NULL),
15 root_container_handle_(gfx::kNullPluginWindow),
16 gpu_rendering_active_(false) {
17 } 14 }
18 15
19 AcceleratedSurfaceContainerManagerMac:: 16 AcceleratedSurfaceContainerManagerMac::
20 ~AcceleratedSurfaceContainerManagerMac() {} 17 ~AcceleratedSurfaceContainerManagerMac() {}
21 18
22 gfx::PluginWindowHandle 19 gfx::PluginWindowHandle
23 AcceleratedSurfaceContainerManagerMac::AllocateFakePluginWindowHandle( 20 AcceleratedSurfaceContainerManagerMac::AllocateFakePluginWindowHandle(
24 bool opaque, bool root) { 21 bool opaque, bool root) {
25 base::AutoLock lock(lock_); 22 base::AutoLock lock(lock_);
26 23
27 AcceleratedSurfaceContainerMac* container = 24 AcceleratedSurfaceContainerMac* container =
28 new AcceleratedSurfaceContainerMac(this, opaque); 25 new AcceleratedSurfaceContainerMac(this, opaque);
29 gfx::PluginWindowHandle res = 26 gfx::PluginWindowHandle res =
30 static_cast<gfx::PluginWindowHandle>(++current_id_); 27 static_cast<gfx::PluginWindowHandle>(++current_id_);
31 plugin_window_to_container_map_.insert(std::make_pair(res, container)); 28 plugin_window_to_container_map_.insert(std::make_pair(res, container));
32 if (root) { 29 DCHECK(!root);
33 root_container_ = container;
34 root_container_handle_ = res;
35 }
36 return res; 30 return res;
37 } 31 }
38 32
39 void AcceleratedSurfaceContainerManagerMac::DestroyFakePluginWindowHandle( 33 void AcceleratedSurfaceContainerManagerMac::DestroyFakePluginWindowHandle(
40 gfx::PluginWindowHandle id) { 34 gfx::PluginWindowHandle id) {
41 base::AutoLock lock(lock_); 35 base::AutoLock lock(lock_);
42 36
43 AcceleratedSurfaceContainerMac* container = MapIDToContainer(id); 37 AcceleratedSurfaceContainerMac* container = MapIDToContainer(id);
44 if (container) { 38 if (container)
45 if (container == root_container_) {
46 root_container_ = NULL;
47 root_container_handle_ = gfx::kNullPluginWindow;
48 }
49 delete container; 39 delete container;
50 }
51 plugin_window_to_container_map_.erase(id); 40 plugin_window_to_container_map_.erase(id);
52 } 41 }
53 42
54 bool AcceleratedSurfaceContainerManagerMac::IsRootContainer(
55 gfx::PluginWindowHandle id) const {
56 return root_container_handle_ != gfx::kNullPluginWindow &&
57 root_container_handle_ == id;
58 }
59
60 void AcceleratedSurfaceContainerManagerMac::
61 set_gpu_rendering_active(bool active) {
62 if (gpu_rendering_active_ && !active)
63 SetRootSurfaceInvalid();
64 gpu_rendering_active_ = active;
65 }
66
67 void AcceleratedSurfaceContainerManagerMac::SetSizeAndIOSurface( 43 void AcceleratedSurfaceContainerManagerMac::SetSizeAndIOSurface(
68 gfx::PluginWindowHandle id, 44 gfx::PluginWindowHandle id,
69 int32 width, 45 int32 width,
70 int32 height, 46 int32 height,
71 uint64 io_surface_identifier) { 47 uint64 io_surface_identifier) {
72 base::AutoLock lock(lock_); 48 base::AutoLock lock(lock_);
73 49
74 AcceleratedSurfaceContainerMac* container = MapIDToContainer(id); 50 AcceleratedSurfaceContainerMac* container = MapIDToContainer(id);
75 if (container) { 51 if (container) {
76 container->SetSizeAndIOSurface(width, height, io_surface_identifier); 52 container->SetSizeAndIOSurface(width, height, io_surface_identifier);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 gfx::PluginWindowHandle id, 126 gfx::PluginWindowHandle id,
151 uint64 surface_handle, 127 uint64 surface_handle,
152 const gfx::Rect& update_rect) { 128 const gfx::Rect& update_rect) {
153 base::AutoLock lock(lock_); 129 base::AutoLock lock(lock_);
154 130
155 AcceleratedSurfaceContainerMac* container = MapIDToContainer(id); 131 AcceleratedSurfaceContainerMac* container = MapIDToContainer(id);
156 if (container) 132 if (container)
157 container->set_was_painted_to(surface_handle, update_rect); 133 container->set_was_painted_to(surface_handle, update_rect);
158 } 134 }
159 135
160 void AcceleratedSurfaceContainerManagerMac::SetRootSurfaceInvalid() {
161 base::AutoLock lock(lock_);
162 if (root_container_)
163 root_container_->set_surface_invalid();
164 }
165
166 bool AcceleratedSurfaceContainerManagerMac::SurfaceShouldBeVisible( 136 bool AcceleratedSurfaceContainerManagerMac::SurfaceShouldBeVisible(
167 gfx::PluginWindowHandle id) const { 137 gfx::PluginWindowHandle id) const {
168 base::AutoLock lock(lock_); 138 base::AutoLock lock(lock_);
169 139
170 if (IsRootContainer(id) && !gpu_rendering_active_)
171 return false;
172
173 AcceleratedSurfaceContainerMac* container = MapIDToContainer(id); 140 AcceleratedSurfaceContainerMac* container = MapIDToContainer(id);
174 return container && container->ShouldBeVisible(); 141 return container && container->ShouldBeVisible();
175 } 142 }
176 143
177 AcceleratedSurfaceContainerMac* 144 AcceleratedSurfaceContainerMac*
178 AcceleratedSurfaceContainerManagerMac::MapIDToContainer( 145 AcceleratedSurfaceContainerManagerMac::MapIDToContainer(
179 gfx::PluginWindowHandle id) const { 146 gfx::PluginWindowHandle id) const {
180 PluginWindowToContainerMap::const_iterator i = 147 PluginWindowToContainerMap::const_iterator i =
181 plugin_window_to_container_map_.find(id); 148 plugin_window_to_container_map_.find(id);
182 if (i != plugin_window_to_container_map_.end()) 149 if (i != plugin_window_to_container_map_.end())
183 return i->second; 150 return i->second;
184 151
185 LOG(ERROR) << "Request for plugin container for unknown window id " << id; 152 LOG(ERROR) << "Request for plugin container for unknown window id " << id;
186 153
187 return NULL; 154 return NULL;
188 } 155 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698