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

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

Issue 3185004: Cleanups to well-behaved accelerated plugin CL requested by... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
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 | Annotate | Revision Log
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 void AcceleratedSurfaceContainerManagerMac::SetSizeAndTransportDIB( 58 void AcceleratedSurfaceContainerManagerMac::SetSizeAndTransportDIB(
59 gfx::PluginWindowHandle id, 59 gfx::PluginWindowHandle id,
60 int32 width, 60 int32 width,
61 int32 height, 61 int32 height,
62 TransportDIB::Handle transport_dib) { 62 TransportDIB::Handle transport_dib) {
63 AcceleratedSurfaceContainerMac* container = MapIDToContainer(id); 63 AcceleratedSurfaceContainerMac* container = MapIDToContainer(id);
64 if (container) 64 if (container)
65 container->SetSizeAndTransportDIB(width, height, transport_dib); 65 container->SetSizeAndTransportDIB(width, height, transport_dib);
66 } 66 }
67 67
68 void AcceleratedSurfaceContainerManagerMac::MovePluginContainer( 68 void AcceleratedSurfaceContainerManagerMac::SetPluginContainerGeometry(
69 const webkit_glue::WebPluginGeometry& move) { 69 const webkit_glue::WebPluginGeometry& move) {
70 AcceleratedSurfaceContainerMac* container = MapIDToContainer(move.window); 70 AcceleratedSurfaceContainerMac* container = MapIDToContainer(move.window);
71 if (container) 71 if (container)
72 container->MoveTo(move); 72 container->SetGeometry(move);
73 } 73 }
74 74
75 void AcceleratedSurfaceContainerManagerMac::Draw(CGLContextObj context, 75 void AcceleratedSurfaceContainerManagerMac::Draw(CGLContextObj context,
76 gfx::PluginWindowHandle id, 76 gfx::PluginWindowHandle id,
77 bool draw_root_container) { 77 bool draw_root_container) {
78 // Clean up old texture objects. This is essentially a pre-emptive
79 // cleanup, as the resources will be released when the OpenGL
80 // context associated with the CAOpenGLLayer is destroyed. However,
81 // if we render many plugins in the same layer, we should try to
82 // eagerly reclaim their resources. Note also that the OpenGL
83 // context must be current when performing the deletion, and it
84 // seems risky to make the OpenGL context current at an arbitrary
85 // point in time, which is why the deletion does not occur in the
86 // container's destructor.
87 for (std::vector<GLuint>::iterator iter =
88 textures_pending_deletion_.begin();
89 iter != textures_pending_deletion_.end();
90 ++iter) {
91 GLuint texture = *iter;
92 glDeleteTextures(1, &texture);
93 }
94 textures_pending_deletion_.clear();
95
96 glColorMask(true, true, true, true); 78 glColorMask(true, true, true, true);
97 glClearColor(0, 0, 0, 0); 79 glClearColor(0, 0, 0, 0);
98 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 80 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
99 glDisable(GL_DEPTH_TEST); 81 glDisable(GL_DEPTH_TEST);
100 glDisable(GL_BLEND); 82 glDisable(GL_BLEND);
101 83
102 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); 84 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
103 85
104 AcceleratedSurfaceContainerMac* container = MapIDToContainer(id); 86 AcceleratedSurfaceContainerMac* container = MapIDToContainer(id);
105 CHECK(container); 87 CHECK(container);
(...skipping 10 matching lines...) Expand all
116 98
117 void AcceleratedSurfaceContainerManagerMac::ForceTextureReload() { 99 void AcceleratedSurfaceContainerManagerMac::ForceTextureReload() {
118 for (PluginWindowToContainerMap::const_iterator i = 100 for (PluginWindowToContainerMap::const_iterator i =
119 plugin_window_to_container_map_.begin(); 101 plugin_window_to_container_map_.begin();
120 i != plugin_window_to_container_map_.end(); ++i) { 102 i != plugin_window_to_container_map_.end(); ++i) {
121 AcceleratedSurfaceContainerMac* container = i->second; 103 AcceleratedSurfaceContainerMac* container = i->second;
122 container->ForceTextureReload(); 104 container->ForceTextureReload();
123 } 105 }
124 } 106 }
125 107
126 void AcceleratedSurfaceContainerManagerMac::EnqueueTextureForDeletion(
127 GLuint texture) {
128 if (texture) {
129 textures_pending_deletion_.push_back(texture);
130 }
131 }
132
133 AcceleratedSurfaceContainerMac* 108 AcceleratedSurfaceContainerMac*
134 AcceleratedSurfaceContainerManagerMac::MapIDToContainer( 109 AcceleratedSurfaceContainerManagerMac::MapIDToContainer(
135 gfx::PluginWindowHandle id) { 110 gfx::PluginWindowHandle id) {
136 PluginWindowToContainerMap::const_iterator i = 111 PluginWindowToContainerMap::const_iterator i =
137 plugin_window_to_container_map_.find(id); 112 plugin_window_to_container_map_.find(id);
138 if (i != plugin_window_to_container_map_.end()) 113 if (i != plugin_window_to_container_map_.end())
139 return i->second; 114 return i->second;
140 115
141 LOG(ERROR) << "Request for plugin container for unknown window id " << id; 116 LOG(ERROR) << "Request for plugin container for unknown window id " << id;
142 117
143 return NULL; 118 return NULL;
144 } 119 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698