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

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

Issue 3010054: Mac: Well-behaved accelerated plugins, preparation (Closed)
Patch Set: '' 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
(...skipping 20 matching lines...) Expand all
31 gfx::PluginWindowHandle id) { 31 gfx::PluginWindowHandle id) {
32 AcceleratedSurfaceContainerMac* container = MapIDToContainer(id); 32 AcceleratedSurfaceContainerMac* container = MapIDToContainer(id);
33 if (container) { 33 if (container) {
34 if (container == root_container_) 34 if (container == root_container_)
35 root_container_ = NULL; 35 root_container_ = NULL;
36 delete container; 36 delete container;
37 } 37 }
38 plugin_window_to_container_map_.erase(id); 38 plugin_window_to_container_map_.erase(id);
39 } 39 }
40 40
41 bool AcceleratedSurfaceContainerManagerMac::HasRootContainer() { 41 bool AcceleratedSurfaceContainerManagerMac::IsRootContainer(
42 return root_container_ != NULL; 42 gfx::PluginWindowHandle id) {
43 AcceleratedSurfaceContainerMac* container = MapIDToContainer(id);
44 return root_container_ == container;
43 } 45 }
44 46
45 void AcceleratedSurfaceContainerManagerMac::SetSizeAndIOSurface( 47 void AcceleratedSurfaceContainerManagerMac::SetSizeAndIOSurface(
46 gfx::PluginWindowHandle id, 48 gfx::PluginWindowHandle id,
47 int32 width, 49 int32 width,
48 int32 height, 50 int32 height,
49 uint64 io_surface_identifier) { 51 uint64 io_surface_identifier) {
50 AcceleratedSurfaceContainerMac* container = MapIDToContainer(id); 52 AcceleratedSurfaceContainerMac* container = MapIDToContainer(id);
51 if (container) { 53 if (container) {
52 container->SetSizeAndIOSurface(width, height, io_surface_identifier); 54 container->SetSizeAndIOSurface(width, height, io_surface_identifier);
53 if (container == root_container_) {
54 // Fake up a WebPluginGeometry for the root window to set the
55 // container's size; we will never get a notification from the
56 // browser about the root window, only plugins.
57 webkit_glue::WebPluginGeometry geom;
58 gfx::Rect rect(0, 0, width, height);
59 geom.window_rect = rect;
60 geom.clip_rect = rect;
61 geom.visible = true;
62 container->MoveTo(geom);
63 }
64 } 55 }
65 } 56 }
66 57
67 void AcceleratedSurfaceContainerManagerMac::SetSizeAndTransportDIB( 58 void AcceleratedSurfaceContainerManagerMac::SetSizeAndTransportDIB(
68 gfx::PluginWindowHandle id, 59 gfx::PluginWindowHandle id,
69 int32 width, 60 int32 width,
70 int32 height, 61 int32 height,
71 TransportDIB::Handle transport_dib) { 62 TransportDIB::Handle transport_dib) {
72 AcceleratedSurfaceContainerMac* container = MapIDToContainer(id); 63 AcceleratedSurfaceContainerMac* container = MapIDToContainer(id);
73 if (container) 64 if (container)
74 container->SetSizeAndTransportDIB(width, height, transport_dib); 65 container->SetSizeAndTransportDIB(width, height, transport_dib);
75 } 66 }
76 67
77 void AcceleratedSurfaceContainerManagerMac::MovePluginContainer( 68 void AcceleratedSurfaceContainerManagerMac::MovePluginContainer(
78 const webkit_glue::WebPluginGeometry& move) { 69 const webkit_glue::WebPluginGeometry& move) {
79 AcceleratedSurfaceContainerMac* container = MapIDToContainer(move.window); 70 AcceleratedSurfaceContainerMac* container = MapIDToContainer(move.window);
80 if (container) 71 if (container)
81 container->MoveTo(move); 72 container->MoveTo(move);
82 } 73 }
83 74
84 void AcceleratedSurfaceContainerManagerMac::Draw(CGLContextObj context, 75 void AcceleratedSurfaceContainerManagerMac::Draw(CGLContextObj context,
76 gfx::PluginWindowHandle id,
85 bool draw_root_container) { 77 bool draw_root_container) {
86 // Clean up old texture objects. This is essentially a pre-emptive 78 // Clean up old texture objects. This is essentially a pre-emptive
87 // cleanup, as the resources will be released when the OpenGL 79 // cleanup, as the resources will be released when the OpenGL
88 // context associated with the CAOpenGLLayer is destroyed. However, 80 // context associated with the CAOpenGLLayer is destroyed. However,
stuartmorgan 2010/08/11 16:40:44 Comment is no longer right.
Ken Russell (switch to Gerrit) 2010/08/14 02:12:11 Actually, because each container is rendered into
89 // if we render many plugins in the same layer, we should try to 81 // if we render many plugins in the same layer, we should try to
90 // eagerly reclaim their resources. Note also that the OpenGL 82 // eagerly reclaim their resources. Note also that the OpenGL
91 // context must be current when performing the deletion, and it 83 // context must be current when performing the deletion, and it
92 // seems risky to make the OpenGL context current at an arbitrary 84 // seems risky to make the OpenGL context current at an arbitrary
93 // point in time, which is why the deletion does not occur in the 85 // point in time, which is why the deletion does not occur in the
94 // container's destructor. 86 // container's destructor.
95 for (std::vector<GLuint>::iterator iter = 87 for (std::vector<GLuint>::iterator iter =
96 textures_pending_deletion_.begin(); 88 textures_pending_deletion_.begin();
97 iter != textures_pending_deletion_.end(); 89 iter != textures_pending_deletion_.end();
98 ++iter) { 90 ++iter) {
99 GLuint texture = *iter; 91 GLuint texture = *iter;
100 glDeleteTextures(1, &texture); 92 glDeleteTextures(1, &texture);
101 } 93 }
102 textures_pending_deletion_.clear(); 94 textures_pending_deletion_.clear();
103 95
104 glColorMask(true, true, true, true); 96 glColorMask(true, true, true, true);
stuartmorgan 2010/08/11 16:40:44 The division between this method and Draw seems pr
Ken Russell (switch to Gerrit) 2010/08/14 02:12:11 I'd rather leave it structured like this in case w
105 glClearColor(0, 0, 0, 0); 97 glClearColor(0, 0, 0, 0);
106 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 98 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
107 glDisable(GL_DEPTH_TEST); 99 glDisable(GL_DEPTH_TEST);
108 glDisable(GL_BLEND); 100 glDisable(GL_BLEND);
109 101
110 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); 102 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
111 103
112 // Draw the root container, if any, first. 104 AcceleratedSurfaceContainerMac* container = MapIDToContainer(id);
113 if (draw_root_container && root_container_) { 105 CHECK(container);
114 root_container_->Draw(context); 106 container->Draw(context);
115 }
116
117 for (PluginWindowToContainerMap::const_iterator i =
118 plugin_window_to_container_map_.begin();
119 i != plugin_window_to_container_map_.end(); ++i) {
120 AcceleratedSurfaceContainerMac* container = i->second;
121 if (container != root_container_) {
122 container->Draw(context);
123 }
124 }
125 107
126 // Unbind any texture from the texture target to ensure that the 108 // Unbind any texture from the texture target to ensure that the
127 // next time through we will have to re-bind the texture and thereby 109 // next time through we will have to re-bind the texture and thereby
128 // pick up modifications from the other process. 110 // pick up modifications from the other process.
129 GLenum target = GL_TEXTURE_RECTANGLE_ARB; 111 GLenum target = GL_TEXTURE_RECTANGLE_ARB;
130 glBindTexture(target, 0); 112 glBindTexture(target, 0);
131 113
132 glFlush(); 114 glFlush();
133 } 115 }
134 116
(...skipping 18 matching lines...) Expand all
153 gfx::PluginWindowHandle id) { 135 gfx::PluginWindowHandle id) {
154 PluginWindowToContainerMap::const_iterator i = 136 PluginWindowToContainerMap::const_iterator i =
155 plugin_window_to_container_map_.find(id); 137 plugin_window_to_container_map_.find(id);
156 if (i != plugin_window_to_container_map_.end()) 138 if (i != plugin_window_to_container_map_.end())
157 return i->second; 139 return i->second;
158 140
159 LOG(ERROR) << "Request for plugin container for unknown window id " << id; 141 LOG(ERROR) << "Request for plugin container for unknown window id " << id;
160 142
161 return NULL; 143 return NULL;
162 } 144 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698