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

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

Issue 8726046: Partial swaps on OSX (Closed) Base URL: backer@fancypants:chromium/src@master
Patch Set: Address reviewer comments. Created 9 years 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_mac.h" 5 #include "content/browser/renderer_host/accelerated_surface_container_mac.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "content/browser/renderer_host/accelerated_surface_container_manager_ma c.h" 8 #include "content/browser/renderer_host/accelerated_surface_container_manager_ma c.h"
9 #include "ui/gfx/surface/io_surface_support_mac.h" 9 #include "ui/gfx/surface/io_surface_support_mac.h"
10 #include "webkit/plugins/npapi/webplugin.h" 10 #include "webkit/plugins/npapi/webplugin.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 surface_width_, 111 surface_width_,
112 surface_height_, 112 surface_height_,
113 GL_BGRA, 113 GL_BGRA,
114 GL_UNSIGNED_INT_8_8_8_8_REV, 114 GL_UNSIGNED_INT_8_8_8_8_REV,
115 surface_.get(), 115 surface_.get(),
116 plane); 116 plane);
117 texture_needs_upload_ = false; 117 texture_needs_upload_ = false;
118 } 118 }
119 // If using TransportDIBs, the texture needs to be uploaded every frame. 119 // If using TransportDIBs, the texture needs to be uploaded every frame.
120 if (transport_dib_.get() != NULL) { 120 if (transport_dib_.get() != NULL) {
121 void* pixel_memory = transport_dib_->memory(); 121 unsigned char* pixel_memory =
122 static_cast<unsigned char*>(transport_dib_->memory());
122 if (pixel_memory) { 123 if (pixel_memory) {
123 glBindTexture(target, texture_); 124 glBindTexture(target, texture_);
124 glPixelStorei(GL_UNPACK_ALIGNMENT, 1); // Needed for NPOT textures. 125 glPixelStorei(GL_UNPACK_ALIGNMENT, 1); // Needed for NPOT textures.
125 glTexSubImage2D(target, 126 if (update_rect_.IsEmpty()) {
126 0, // mipmap level 0 127 glTexSubImage2D(target,
127 0, // x-offset 128 0, // mipmap level 0
128 0, // y-offset 129 0, // x-offset
129 width_, 130 0, // y-offset
130 height_, 131 width_,
131 GL_BGRA, // The GPU plugin gave us BGRA pixels 132 height_,
132 GL_UNSIGNED_INT_8_8_8_8_REV, 133 GL_BGRA, // The GPU plugin gave us BGRA pixels
133 pixel_memory); 134 GL_UNSIGNED_INT_8_8_8_8_REV,
135 pixel_memory);
136 } else {
137 glPixelStorei(GL_UNPACK_ROW_LENGTH, width_);
138 glTexSubImage2D(target,
139 0, // mipmap level 0
140 update_rect_.x(), // x-offset
141 update_rect_.y(), // y-offset
142 update_rect_.width(),
143 update_rect_.height(),
144 GL_BGRA, // The GPU plugin gave us BGRA pixels
145 GL_UNSIGNED_INT_8_8_8_8_REV,
146 &pixel_memory[(update_rect_.x() +
147 update_rect_.y() * width_) * 4]);
148 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
149 }
134 } 150 }
135 } 151 }
152 update_rect_ = gfx::Rect();
136 153
137 if (texture_) { 154 if (texture_) {
138 int texture_width = io_surface_support ? surface_width_ : width_; 155 int texture_width = io_surface_support ? surface_width_ : width_;
139 int texture_height = io_surface_support ? surface_height_ : height_; 156 int texture_height = io_surface_support ? surface_height_ : height_;
140 157
141 // TODO(kbr): convert this to use only OpenGL ES 2.0 functionality. 158 // TODO(kbr): convert this to use only OpenGL ES 2.0 functionality.
142 159
143 // TODO(kbr): may need to pay attention to cutout rects. 160 // TODO(kbr): may need to pay attention to cutout rects.
144 int clipX = clip_rect_.x(); 161 int clipX = clip_rect_.x();
145 int clipY = clip_rect_.y(); 162 int clipY = clip_rect_.y();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 glEnd(); 213 glEnd();
197 glDisable(target); 214 glDisable(target);
198 } 215 }
199 } 216 }
200 217
201 bool AcceleratedSurfaceContainerMac::ShouldBeVisible() const { 218 bool AcceleratedSurfaceContainerMac::ShouldBeVisible() const {
202 return visible_ && was_painted_to_ && !clip_rect_.IsEmpty(); 219 return visible_ && was_painted_to_ && !clip_rect_.IsEmpty();
203 } 220 }
204 221
205 void AcceleratedSurfaceContainerMac::set_was_painted_to(uint64 surface_id) { 222 void AcceleratedSurfaceContainerMac::set_was_painted_to(uint64 surface_id) {
223 set_was_painted_to_common(surface_id);
224 update_rect_ = gfx::Rect();
225 }
226
227 void AcceleratedSurfaceContainerMac::set_was_painted_to(
228 uint64 surface_id,
229 const gfx::Rect& update_rect) {
230 set_was_painted_to_common(surface_id);
231 update_rect_ = update_rect_.Union(update_rect);
232 }
233
234 void AcceleratedSurfaceContainerMac::EnqueueTextureForDeletion() {
235 if (texture_) {
236 DCHECK(texture_pending_deletion_ == 0);
237 texture_pending_deletion_ = texture_;
238 texture_ = 0;
239 }
240 }
241
242 void AcceleratedSurfaceContainerMac::set_was_painted_to_common(
243 uint64 surface_id) {
206 if (surface_id && (!surface_ || surface_id != surface_id_)) { 244 if (surface_id && (!surface_ || surface_id != surface_id_)) {
207 // Keep the surface that was most recently painted to around. 245 // Keep the surface that was most recently painted to around.
208 if (IOSurfaceSupport* io_surface_support = IOSurfaceSupport::Initialize()) { 246 if (IOSurfaceSupport* io_surface_support = IOSurfaceSupport::Initialize()) {
209 CFTypeRef surface = io_surface_support->IOSurfaceLookup( 247 CFTypeRef surface = io_surface_support->IOSurfaceLookup(
210 static_cast<uint32>(surface_id)); 248 static_cast<uint32>(surface_id));
211 // Can fail if IOSurface with that ID was already released by the 249 // Can fail if IOSurface with that ID was already released by the
212 // gpu process or the plugin process. We will get a |set_was_painted_to()| 250 // gpu process or the plugin process. We will get a |set_was_painted_to()|
213 // message with a new surface soon in that case. 251 // message with a new surface soon in that case.
214 if (surface) { 252 if (surface) {
215 surface_.reset(surface); 253 surface_.reset(surface);
216 surface_id_ = surface_id; 254 surface_id_ = surface_id;
217 surface_width_ = io_surface_support->IOSurfaceGetWidth(surface_); 255 surface_width_ = io_surface_support->IOSurfaceGetWidth(surface_);
218 surface_height_ = io_surface_support->IOSurfaceGetHeight(surface_); 256 surface_height_ = io_surface_support->IOSurfaceGetHeight(surface_);
219 EnqueueTextureForDeletion(); 257 EnqueueTextureForDeletion();
220 } 258 }
221 } 259 }
222 } 260 }
223 was_painted_to_ = true; 261 was_painted_to_ = true;
224 } 262 }
225
226 void AcceleratedSurfaceContainerMac::EnqueueTextureForDeletion() {
227 if (texture_) {
228 DCHECK(texture_pending_deletion_ == 0);
229 texture_pending_deletion_ = texture_;
230 texture_ = 0;
231 }
232 }
233
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698