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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/accelerated_surface_container_mac.cc
diff --git a/content/browser/renderer_host/accelerated_surface_container_mac.cc b/content/browser/renderer_host/accelerated_surface_container_mac.cc
index e76103ce5711492fadee3e1187da071ad1b23139..86875f3c09f36179fd3cd92db4ac6f37dc49a0fa 100644
--- a/content/browser/renderer_host/accelerated_surface_container_mac.cc
+++ b/content/browser/renderer_host/accelerated_surface_container_mac.cc
@@ -118,21 +118,38 @@ void AcceleratedSurfaceContainerMac::Draw(CGLContextObj context) {
}
// If using TransportDIBs, the texture needs to be uploaded every frame.
if (transport_dib_.get() != NULL) {
- void* pixel_memory = transport_dib_->memory();
+ unsigned char* pixel_memory =
+ static_cast<unsigned char*>(transport_dib_->memory());
if (pixel_memory) {
glBindTexture(target, texture_);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1); // Needed for NPOT textures.
- glTexSubImage2D(target,
- 0, // mipmap level 0
- 0, // x-offset
- 0, // y-offset
- width_,
- height_,
- GL_BGRA, // The GPU plugin gave us BGRA pixels
- GL_UNSIGNED_INT_8_8_8_8_REV,
- pixel_memory);
+ if (update_rect_.IsEmpty()) {
+ glTexSubImage2D(target,
+ 0, // mipmap level 0
+ 0, // x-offset
+ 0, // y-offset
+ width_,
+ height_,
+ GL_BGRA, // The GPU plugin gave us BGRA pixels
+ GL_UNSIGNED_INT_8_8_8_8_REV,
+ pixel_memory);
+ } else {
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, width_);
+ glTexSubImage2D(target,
+ 0, // mipmap level 0
+ update_rect_.x(), // x-offset
+ update_rect_.y(), // y-offset
+ update_rect_.width(),
+ update_rect_.height(),
+ GL_BGRA, // The GPU plugin gave us BGRA pixels
+ GL_UNSIGNED_INT_8_8_8_8_REV,
+ &pixel_memory[(update_rect_.x() +
+ update_rect_.y() * width_) * 4]);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+ }
}
}
+ update_rect_ = gfx::Rect();
if (texture_) {
int texture_width = io_surface_support ? surface_width_ : width_;
@@ -203,6 +220,27 @@ bool AcceleratedSurfaceContainerMac::ShouldBeVisible() const {
}
void AcceleratedSurfaceContainerMac::set_was_painted_to(uint64 surface_id) {
+ set_was_painted_to_common(surface_id);
+ update_rect_ = gfx::Rect();
+}
+
+void AcceleratedSurfaceContainerMac::set_was_painted_to(
+ uint64 surface_id,
+ const gfx::Rect& update_rect) {
+ set_was_painted_to_common(surface_id);
+ update_rect_ = update_rect_.Union(update_rect);
+}
+
+void AcceleratedSurfaceContainerMac::EnqueueTextureForDeletion() {
+ if (texture_) {
+ DCHECK(texture_pending_deletion_ == 0);
+ texture_pending_deletion_ = texture_;
+ texture_ = 0;
+ }
+}
+
+void AcceleratedSurfaceContainerMac::set_was_painted_to_common(
+ uint64 surface_id) {
if (surface_id && (!surface_ || surface_id != surface_id_)) {
// Keep the surface that was most recently painted to around.
if (IOSurfaceSupport* io_surface_support = IOSurfaceSupport::Initialize()) {
@@ -222,12 +260,3 @@ void AcceleratedSurfaceContainerMac::set_was_painted_to(uint64 surface_id) {
}
was_painted_to_ = true;
}
-
-void AcceleratedSurfaceContainerMac::EnqueueTextureForDeletion() {
- if (texture_) {
- DCHECK(texture_pending_deletion_ == 0);
- texture_pending_deletion_ = texture_;
- texture_ = 0;
- }
-}
-

Powered by Google App Engine
This is Rietveld 408576698