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

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

Issue 3067026: Initial port of accelerated compositor to Mac OS X 10.6. Reused... (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
11 AcceleratedSurfaceContainerManagerMac::AcceleratedSurfaceContainerManagerMac() 11 AcceleratedSurfaceContainerManagerMac::AcceleratedSurfaceContainerManagerMac()
12 : current_id_(0) { 12 : current_id_(0),
13 root_container_(NULL) {
13 } 14 }
14 15
15 gfx::PluginWindowHandle 16 gfx::PluginWindowHandle
16 AcceleratedSurfaceContainerManagerMac::AllocateFakePluginWindowHandle( 17 AcceleratedSurfaceContainerManagerMac::AllocateFakePluginWindowHandle(
17 bool opaque) { 18 bool opaque, bool root) {
18 AcceleratedSurfaceContainerMac* container = 19 AcceleratedSurfaceContainerMac* container =
19 new AcceleratedSurfaceContainerMac(this, opaque); 20 new AcceleratedSurfaceContainerMac(this, opaque);
20 gfx::PluginWindowHandle res = 21 gfx::PluginWindowHandle res =
21 static_cast<gfx::PluginWindowHandle>(++current_id_); 22 static_cast<gfx::PluginWindowHandle>(++current_id_);
22 plugin_window_to_container_map_.insert(std::make_pair(res, container)); 23 plugin_window_to_container_map_.insert(std::make_pair(res, container));
24 if (root) {
25 root_container_ = container;
26 }
23 return res; 27 return res;
24 } 28 }
25 29
26 void AcceleratedSurfaceContainerManagerMac::DestroyFakePluginWindowHandle( 30 void AcceleratedSurfaceContainerManagerMac::DestroyFakePluginWindowHandle(
27 gfx::PluginWindowHandle id) { 31 gfx::PluginWindowHandle id) {
28 AcceleratedSurfaceContainerMac* container = MapIDToContainer(id); 32 AcceleratedSurfaceContainerMac* container = MapIDToContainer(id);
29 if (container) 33 if (container) {
34 if (container == root_container_)
35 root_container_ = NULL;
30 delete container; 36 delete container;
37 }
31 plugin_window_to_container_map_.erase(id); 38 plugin_window_to_container_map_.erase(id);
32 } 39 }
33 40
41 bool AcceleratedSurfaceContainerManagerMac::HasRootContainer() {
42 return root_container_ != NULL;
43 }
44
34 void AcceleratedSurfaceContainerManagerMac::SetSizeAndIOSurface( 45 void AcceleratedSurfaceContainerManagerMac::SetSizeAndIOSurface(
35 gfx::PluginWindowHandle id, 46 gfx::PluginWindowHandle id,
36 int32 width, 47 int32 width,
37 int32 height, 48 int32 height,
38 uint64 io_surface_identifier) { 49 uint64 io_surface_identifier) {
39 AcceleratedSurfaceContainerMac* container = MapIDToContainer(id); 50 AcceleratedSurfaceContainerMac* container = MapIDToContainer(id);
40 if (container) 51 if (container) {
41 container->SetSizeAndIOSurface(width, height, io_surface_identifier); 52 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 }
42 } 65 }
43 66
44 void AcceleratedSurfaceContainerManagerMac::SetSizeAndTransportDIB( 67 void AcceleratedSurfaceContainerManagerMac::SetSizeAndTransportDIB(
45 gfx::PluginWindowHandle id, 68 gfx::PluginWindowHandle id,
46 int32 width, 69 int32 width,
47 int32 height, 70 int32 height,
48 TransportDIB::Handle transport_dib) { 71 TransportDIB::Handle transport_dib) {
49 AcceleratedSurfaceContainerMac* container = MapIDToContainer(id); 72 AcceleratedSurfaceContainerMac* container = MapIDToContainer(id);
50 if (container) 73 if (container)
51 container->SetSizeAndTransportDIB(width, height, transport_dib); 74 container->SetSizeAndTransportDIB(width, height, transport_dib);
52 } 75 }
53 76
54 void AcceleratedSurfaceContainerManagerMac::MovePluginContainer( 77 void AcceleratedSurfaceContainerManagerMac::MovePluginContainer(
55 const webkit_glue::WebPluginGeometry& move) { 78 const webkit_glue::WebPluginGeometry& move) {
56 AcceleratedSurfaceContainerMac* container = MapIDToContainer(move.window); 79 AcceleratedSurfaceContainerMac* container = MapIDToContainer(move.window);
57 if (container) 80 if (container)
58 container->MoveTo(move); 81 container->MoveTo(move);
59 } 82 }
60 83
61 void AcceleratedSurfaceContainerManagerMac::Draw(CGLContextObj context) { 84 void AcceleratedSurfaceContainerManagerMac::Draw(CGLContextObj context,
85 bool draw_root_container) {
62 // Clean up old texture objects. This is essentially a pre-emptive 86 // Clean up old texture objects. This is essentially a pre-emptive
63 // cleanup, as the resources will be released when the OpenGL 87 // cleanup, as the resources will be released when the OpenGL
64 // context associated with the CAOpenGLLayer is destroyed. However, 88 // context associated with the CAOpenGLLayer is destroyed. However,
65 // if we render many plugins in the same layer, we should try to 89 // if we render many plugins in the same layer, we should try to
66 // eagerly reclaim their resources. Note also that the OpenGL 90 // eagerly reclaim their resources. Note also that the OpenGL
67 // context must be current when performing the deletion, and it 91 // context must be current when performing the deletion, and it
68 // seems risky to make the OpenGL context current at an arbitrary 92 // seems risky to make the OpenGL context current at an arbitrary
69 // point in time, which is why the deletion does not occur in the 93 // point in time, which is why the deletion does not occur in the
70 // container's destructor. 94 // container's destructor.
71 for (std::vector<GLuint>::iterator iter = 95 for (std::vector<GLuint>::iterator iter =
72 textures_pending_deletion_.begin(); 96 textures_pending_deletion_.begin();
73 iter != textures_pending_deletion_.end(); 97 iter != textures_pending_deletion_.end();
74 ++iter) { 98 ++iter) {
75 GLuint texture = *iter; 99 GLuint texture = *iter;
76 glDeleteTextures(1, &texture); 100 glDeleteTextures(1, &texture);
77 } 101 }
78 textures_pending_deletion_.clear(); 102 textures_pending_deletion_.clear();
79 103
80 glColorMask(true, true, true, true); 104 glColorMask(true, true, true, true);
81 glClearColor(0, 0, 0, 0); 105 glClearColor(0, 0, 0, 0);
82 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 106 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
83 glDisable(GL_DEPTH_TEST); 107 glDisable(GL_DEPTH_TEST);
84 glDisable(GL_BLEND); 108 glDisable(GL_BLEND);
85 109
86 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); 110 glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
87 111
112 // Draw the root container, if any, first.
113 if (draw_root_container && root_container_) {
114 root_container_->Draw(context);
115 }
116
88 for (PluginWindowToContainerMap::const_iterator i = 117 for (PluginWindowToContainerMap::const_iterator i =
89 plugin_window_to_container_map_.begin(); 118 plugin_window_to_container_map_.begin();
90 i != plugin_window_to_container_map_.end(); ++i) { 119 i != plugin_window_to_container_map_.end(); ++i) {
91 AcceleratedSurfaceContainerMac* container = i->second; 120 AcceleratedSurfaceContainerMac* container = i->second;
92 container->Draw(context); 121 if (container != root_container_) {
122 container->Draw(context);
123 }
93 } 124 }
94 125
95 // Unbind any texture from the texture target to ensure that the 126 // Unbind any texture from the texture target to ensure that the
96 // next time through we will have to re-bind the texture and thereby 127 // next time through we will have to re-bind the texture and thereby
97 // pick up modifications from the other process. 128 // pick up modifications from the other process.
98 GLenum target = GL_TEXTURE_RECTANGLE_ARB; 129 GLenum target = GL_TEXTURE_RECTANGLE_ARB;
99 glBindTexture(target, 0); 130 glBindTexture(target, 0);
100 131
101 glFlush(); 132 glFlush();
102 } 133 }
(...skipping 19 matching lines...) Expand all
122 gfx::PluginWindowHandle id) { 153 gfx::PluginWindowHandle id) {
123 PluginWindowToContainerMap::const_iterator i = 154 PluginWindowToContainerMap::const_iterator i =
124 plugin_window_to_container_map_.find(id); 155 plugin_window_to_container_map_.find(id);
125 if (i != plugin_window_to_container_map_.end()) 156 if (i != plugin_window_to_container_map_.end())
126 return i->second; 157 return i->second;
127 158
128 LOG(ERROR) << "Request for plugin container for unknown window id " << id; 159 LOG(ERROR) << "Request for plugin container for unknown window id " << id;
129 160
130 return NULL; 161 return NULL;
131 } 162 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698