| OLD | NEW |
| 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" |
| 11 | 11 |
| 12 AcceleratedSurfaceContainerMac::AcceleratedSurfaceContainerMac( | 12 AcceleratedSurfaceContainerMac::AcceleratedSurfaceContainerMac( |
| 13 AcceleratedSurfaceContainerManagerMac* manager, | 13 AcceleratedSurfaceContainerManagerMac* manager, |
| 14 bool opaque) | 14 bool opaque) |
| 15 : manager_(manager), | 15 : manager_(manager), |
| 16 opaque_(opaque), | 16 opaque_(opaque), |
| 17 surface_id_(0), | 17 surface_handle_(0), |
| 18 width_(0), | 18 width_(0), |
| 19 height_(0), | 19 height_(0), |
| 20 texture_(0), | 20 texture_(0), |
| 21 texture_needs_upload_(true), | 21 texture_needs_upload_(true), |
| 22 texture_pending_deletion_(0), | 22 texture_pending_deletion_(0), |
| 23 visible_(false), | 23 visible_(false), |
| 24 was_painted_to_(false) { | 24 was_painted_to_(false) { |
| 25 } | 25 } |
| 26 | 26 |
| 27 AcceleratedSurfaceContainerMac::~AcceleratedSurfaceContainerMac() { | 27 AcceleratedSurfaceContainerMac::~AcceleratedSurfaceContainerMac() { |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 | 212 |
| 213 glEnd(); | 213 glEnd(); |
| 214 glDisable(target); | 214 glDisable(target); |
| 215 } | 215 } |
| 216 } | 216 } |
| 217 | 217 |
| 218 bool AcceleratedSurfaceContainerMac::ShouldBeVisible() const { | 218 bool AcceleratedSurfaceContainerMac::ShouldBeVisible() const { |
| 219 return visible_ && was_painted_to_ && !clip_rect_.IsEmpty(); | 219 return visible_ && was_painted_to_ && !clip_rect_.IsEmpty(); |
| 220 } | 220 } |
| 221 | 221 |
| 222 void AcceleratedSurfaceContainerMac::set_was_painted_to(uint64 surface_id) { | 222 void AcceleratedSurfaceContainerMac::set_was_painted_to(uint64 surface_handle) { |
| 223 set_was_painted_to_common(surface_id); | 223 set_was_painted_to_common(surface_handle); |
| 224 update_rect_ = gfx::Rect(); | 224 update_rect_ = gfx::Rect(); |
| 225 } | 225 } |
| 226 | 226 |
| 227 void AcceleratedSurfaceContainerMac::set_was_painted_to( | 227 void AcceleratedSurfaceContainerMac::set_was_painted_to( |
| 228 uint64 surface_id, | 228 uint64 surface_handle, |
| 229 const gfx::Rect& update_rect) { | 229 const gfx::Rect& update_rect) { |
| 230 set_was_painted_to_common(surface_id); | 230 set_was_painted_to_common(surface_handle); |
| 231 update_rect_ = update_rect_.Union(update_rect); | 231 update_rect_ = update_rect_.Union(update_rect); |
| 232 } | 232 } |
| 233 | 233 |
| 234 void AcceleratedSurfaceContainerMac::EnqueueTextureForDeletion() { | 234 void AcceleratedSurfaceContainerMac::EnqueueTextureForDeletion() { |
| 235 if (texture_) { | 235 if (texture_) { |
| 236 DCHECK(texture_pending_deletion_ == 0); | 236 DCHECK(texture_pending_deletion_ == 0); |
| 237 texture_pending_deletion_ = texture_; | 237 texture_pending_deletion_ = texture_; |
| 238 texture_ = 0; | 238 texture_ = 0; |
| 239 } | 239 } |
| 240 } | 240 } |
| 241 | 241 |
| 242 void AcceleratedSurfaceContainerMac::set_was_painted_to_common( | 242 void AcceleratedSurfaceContainerMac::set_was_painted_to_common( |
| 243 uint64 surface_id) { | 243 uint64 surface_handle) { |
| 244 if (surface_id && (!surface_ || surface_id != surface_id_)) { | 244 if (surface_handle && (!surface_ || surface_handle != surface_handle_)) { |
| 245 // Keep the surface that was most recently painted to around. | 245 // Keep the surface that was most recently painted to around. |
| 246 if (IOSurfaceSupport* io_surface_support = IOSurfaceSupport::Initialize()) { | 246 if (IOSurfaceSupport* io_surface_support = IOSurfaceSupport::Initialize()) { |
| 247 CFTypeRef surface = io_surface_support->IOSurfaceLookup( | 247 CFTypeRef surface = io_surface_support->IOSurfaceLookup( |
| 248 static_cast<uint32>(surface_id)); | 248 static_cast<uint32>(surface_handle)); |
| 249 // 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 |
| 250 // 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()| |
| 251 // message with a new surface soon in that case. | 251 // message with a new surface soon in that case. |
| 252 if (surface) { | 252 if (surface) { |
| 253 surface_.reset(surface); | 253 surface_.reset(surface); |
| 254 surface_id_ = surface_id; | 254 surface_handle_ = surface_handle; |
| 255 surface_width_ = io_surface_support->IOSurfaceGetWidth(surface_); | 255 surface_width_ = io_surface_support->IOSurfaceGetWidth(surface_); |
| 256 surface_height_ = io_surface_support->IOSurfaceGetHeight(surface_); | 256 surface_height_ = io_surface_support->IOSurfaceGetHeight(surface_); |
| 257 EnqueueTextureForDeletion(); | 257 EnqueueTextureForDeletion(); |
| 258 } | 258 } |
| 259 } | 259 } |
| 260 } | 260 } |
| 261 was_painted_to_ = true; | 261 was_painted_to_ = true; |
| 262 } | 262 } |
| OLD | NEW |