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

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

Issue 3132038: Mac: Correctly show/hide compositor on navigations. (Closed)
Patch Set: comment Created 10 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
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/browser/renderer_host/accelerated_surface_container_manager_mac .h" 5 #include "chrome/browser/renderer_host/accelerated_surface_container_manager_mac .h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/renderer_host/accelerated_surface_container_mac.h" 8 #include "chrome/browser/renderer_host/accelerated_surface_container_mac.h"
9 #include "webkit/glue/plugins/webplugin.h" 9 #include "webkit/glue/plugins/webplugin.h"
10 10
11 AcceleratedSurfaceContainerManagerMac::AcceleratedSurfaceContainerManagerMac() 11 AcceleratedSurfaceContainerManagerMac::AcceleratedSurfaceContainerManagerMac()
12 : current_id_(0), 12 : current_id_(0),
13 root_container_(NULL) { 13 root_container_(NULL),
14 root_container_handle_(gfx::kNullPluginWindow),
15 gpu_rendering_active_(false) {
14 } 16 }
15 17
16 gfx::PluginWindowHandle 18 gfx::PluginWindowHandle
17 AcceleratedSurfaceContainerManagerMac::AllocateFakePluginWindowHandle( 19 AcceleratedSurfaceContainerManagerMac::AllocateFakePluginWindowHandle(
18 bool opaque, bool root) { 20 bool opaque, bool root) {
19 AcceleratedSurfaceContainerMac* container = 21 AcceleratedSurfaceContainerMac* container =
20 new AcceleratedSurfaceContainerMac(this, opaque); 22 new AcceleratedSurfaceContainerMac(this, opaque);
21 gfx::PluginWindowHandle res = 23 gfx::PluginWindowHandle res =
22 static_cast<gfx::PluginWindowHandle>(++current_id_); 24 static_cast<gfx::PluginWindowHandle>(++current_id_);
23 plugin_window_to_container_map_.insert(std::make_pair(res, container)); 25 plugin_window_to_container_map_.insert(std::make_pair(res, container));
24 if (root) { 26 if (root) {
25 root_container_ = container; 27 root_container_ = container;
28 root_container_handle_ = res;
26 } 29 }
27 return res; 30 return res;
28 } 31 }
29 32
30 void AcceleratedSurfaceContainerManagerMac::DestroyFakePluginWindowHandle( 33 void AcceleratedSurfaceContainerManagerMac::DestroyFakePluginWindowHandle(
31 gfx::PluginWindowHandle id) { 34 gfx::PluginWindowHandle id) {
32 AcceleratedSurfaceContainerMac* container = MapIDToContainer(id); 35 AcceleratedSurfaceContainerMac* container = MapIDToContainer(id);
33 if (container) { 36 if (container) {
34 if (container == root_container_) 37 if (container == root_container_) {
35 root_container_ = NULL; 38 root_container_ = NULL;
39 root_container_handle_ = gfx::kNullPluginWindow;
40 }
36 delete container; 41 delete container;
37 } 42 }
38 plugin_window_to_container_map_.erase(id); 43 plugin_window_to_container_map_.erase(id);
39 } 44 }
40 45
41 bool AcceleratedSurfaceContainerManagerMac::IsRootContainer( 46 bool AcceleratedSurfaceContainerManagerMac::IsRootContainer(
42 gfx::PluginWindowHandle id) { 47 gfx::PluginWindowHandle id) const {
43 AcceleratedSurfaceContainerMac* container = MapIDToContainer(id); 48 return root_container_handle_ != gfx::kNullPluginWindow &&
44 return root_container_ == container; 49 root_container_handle_ == id;
45 } 50 }
46 51
47 void AcceleratedSurfaceContainerManagerMac::SetSizeAndIOSurface( 52 void AcceleratedSurfaceContainerManagerMac::SetSizeAndIOSurface(
48 gfx::PluginWindowHandle id, 53 gfx::PluginWindowHandle id,
49 int32 width, 54 int32 width,
50 int32 height, 55 int32 height,
51 uint64 io_surface_identifier) { 56 uint64 io_surface_identifier) {
52 AcceleratedSurfaceContainerMac* container = MapIDToContainer(id); 57 AcceleratedSurfaceContainerMac* container = MapIDToContainer(id);
53 if (container) { 58 if (container) {
54 container->SetSizeAndIOSurface(width, height, io_surface_identifier); 59 container->SetSizeAndIOSurface(width, height, io_surface_identifier);
(...skipping 11 matching lines...) Expand all
66 } 71 }
67 72
68 void AcceleratedSurfaceContainerManagerMac::SetPluginContainerGeometry( 73 void AcceleratedSurfaceContainerManagerMac::SetPluginContainerGeometry(
69 const webkit_glue::WebPluginGeometry& move) { 74 const webkit_glue::WebPluginGeometry& move) {
70 AcceleratedSurfaceContainerMac* container = MapIDToContainer(move.window); 75 AcceleratedSurfaceContainerMac* container = MapIDToContainer(move.window);
71 if (container) 76 if (container)
72 container->SetGeometry(move); 77 container->SetGeometry(move);
73 } 78 }
74 79
75 void AcceleratedSurfaceContainerManagerMac::Draw(CGLContextObj context, 80 void AcceleratedSurfaceContainerManagerMac::Draw(CGLContextObj context,
76 gfx::PluginWindowHandle id, 81 gfx::PluginWindowHandle id) {
77 bool draw_root_container) {
78 glColorMask(true, true, true, true); 82 glColorMask(true, true, true, true);
79 glClearColor(0, 0, 0, 0); 83 glClearColor(0, 0, 0, 0);
80 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 84 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
81 glDisable(GL_DEPTH_TEST); 85 glDisable(GL_DEPTH_TEST);
82 glDisable(GL_BLEND); 86 glDisable(GL_BLEND);
83 87
84 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); 88 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
85 89
86 AcceleratedSurfaceContainerMac* container = MapIDToContainer(id); 90 AcceleratedSurfaceContainerMac* container = MapIDToContainer(id);
87 CHECK(container); 91 CHECK(container);
(...skipping 19 matching lines...) Expand all
107 111
108 void AcceleratedSurfaceContainerManagerMac::SetSurfaceWasPaintedTo( 112 void AcceleratedSurfaceContainerManagerMac::SetSurfaceWasPaintedTo(
109 gfx::PluginWindowHandle id) { 113 gfx::PluginWindowHandle id) {
110 AcceleratedSurfaceContainerMac* container = MapIDToContainer(id); 114 AcceleratedSurfaceContainerMac* container = MapIDToContainer(id);
111 if (container) 115 if (container)
112 container->set_was_painted_to(); 116 container->set_was_painted_to();
113 } 117 }
114 118
115 bool AcceleratedSurfaceContainerManagerMac::SurfaceShouldBeVisible( 119 bool AcceleratedSurfaceContainerManagerMac::SurfaceShouldBeVisible(
116 gfx::PluginWindowHandle id) const { 120 gfx::PluginWindowHandle id) const {
121 if (IsRootContainer(id) && !gpu_rendering_active_)
122 return false;
123
117 AcceleratedSurfaceContainerMac* container = MapIDToContainer(id); 124 AcceleratedSurfaceContainerMac* container = MapIDToContainer(id);
118 return container && container->should_be_visible(); 125 return container && container->should_be_visible();
119 } 126 }
120 127
121 AcceleratedSurfaceContainerMac* 128 AcceleratedSurfaceContainerMac*
122 AcceleratedSurfaceContainerManagerMac::MapIDToContainer( 129 AcceleratedSurfaceContainerManagerMac::MapIDToContainer(
123 gfx::PluginWindowHandle id) const { 130 gfx::PluginWindowHandle id) const {
124 PluginWindowToContainerMap::const_iterator i = 131 PluginWindowToContainerMap::const_iterator i =
125 plugin_window_to_container_map_.find(id); 132 plugin_window_to_container_map_.find(id);
126 if (i != plugin_window_to_container_map_.end()) 133 if (i != plugin_window_to_container_map_.end())
127 return i->second; 134 return i->second;
128 135
129 LOG(ERROR) << "Request for plugin container for unknown window id " << id; 136 LOG(ERROR) << "Request for plugin container for unknown window id " << id;
130 137
131 return NULL; 138 return NULL;
132 } 139 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698