Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/compositor/buffer_queue.h" | 5 #include "content/browser/compositor/buffer_queue.h" |
| 6 | 6 |
| 7 #include "content/browser/compositor/image_transport_factory.h" | 7 #include "content/browser/compositor/image_transport_factory.h" |
| 8 #include "content/common/gpu/client/context_provider_command_buffer.h" | 8 #include "content/common/gpu/client/context_provider_command_buffer.h" |
| 9 #include "content/common/gpu/client/gl_helper.h" | 9 #include "content/common/gpu/client/gl_helper.h" |
| 10 #include "gpu/GLES2/gl2extchromium.h" | 10 #include "gpu/GLES2/gl2extchromium.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 new_damage.y(), | 63 new_damage.y(), |
| 64 new_damage.width(), | 64 new_damage.width(), |
| 65 new_damage.height())), | 65 new_damage.height())), |
| 66 SkRegion(SkIRect::MakeXYWH(old_damage.x(), | 66 SkRegion(SkIRect::MakeXYWH(old_damage.x(), |
| 67 old_damage.y(), | 67 old_damage.y(), |
| 68 old_damage.width(), | 68 old_damage.width(), |
| 69 old_damage.height()))); | 69 old_damage.height()))); |
| 70 } | 70 } |
| 71 | 71 |
| 72 void BufferQueue::UpdateBufferDamage(const gfx::Rect& damage) { | 72 void BufferQueue::UpdateBufferDamage(const gfx::Rect& damage) { |
| 73 for (size_t i = 0; i < available_surfaces_.size(); i++) | 73 for (size_t i = 0; i < display_queue_surfaces_.size(); i++) |
| 74 available_surfaces_[i].damage.Union(damage); | 74 display_queue_surfaces_[i].damage.Union(damage); |
|
achaulk
2014/12/05 20:12:20
This would have to stay to handle rare cases
| |
| 75 for (std::deque<AllocatedSurface>::iterator it = | 75 for (std::deque<AllocatedSurface>::iterator it = |
| 76 in_flight_surfaces_.begin(); | 76 in_flight_surfaces_.begin(); |
| 77 it != in_flight_surfaces_.end(); | 77 it != in_flight_surfaces_.end(); |
| 78 ++it) | 78 ++it) |
| 79 it->damage.Union(damage); | 79 it->damage.Union(damage); |
| 80 } | 80 } |
| 81 | 81 |
| 82 void BufferQueue::SwapBuffers(const gfx::Rect& damage) { | 82 void BufferQueue::SwapBuffers(const gfx::Rect& damage) { |
| 83 if (damage != gfx::Rect(size_)) { | 83 if (damage != gfx::Rect(size_)) { |
| 84 // We must have a frame available to copy from. | 84 // We must have a frame available to copy from. |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 104 // TODO: add stencil buffer when needed. | 104 // TODO: add stencil buffer when needed. |
| 105 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); | 105 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); |
| 106 gl->BindFramebuffer(GL_FRAMEBUFFER, fbo_); | 106 gl->BindFramebuffer(GL_FRAMEBUFFER, fbo_); |
| 107 gl->FramebufferTexture2D( | 107 gl->FramebufferTexture2D( |
| 108 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0); | 108 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0); |
| 109 | 109 |
| 110 FreeAllSurfaces(); | 110 FreeAllSurfaces(); |
| 111 } | 111 } |
| 112 | 112 |
| 113 void BufferQueue::PageFlipComplete() { | 113 void BufferQueue::PageFlipComplete() { |
| 114 // The surface is already displayed on screen and is available for use. | |
| 115 if (display_queue_surfaces_.size() > 0) { | |
| 116 available_surfaces_.push_back(display_queue_surfaces_.front()); | |
| 117 display_queue_surfaces_.pop_front(); | |
|
achaulk
2014/12/05 20:12:19
I'm not sure what the point of this extra list (of
| |
| 118 } | |
| 119 | |
| 120 // We have requested page flip for the surface and it's waiting to be | |
| 121 // displayed. Let's not put it back to free list yet. | |
| 114 if (in_flight_surfaces_.size() > 1) { | 122 if (in_flight_surfaces_.size() > 1) { |
| 115 available_surfaces_.push_back(in_flight_surfaces_.front()); | 123 display_queue_surfaces_.push_back(in_flight_surfaces_.front()); |
| 116 in_flight_surfaces_.pop_front(); | 124 in_flight_surfaces_.pop_front(); |
| 117 } | 125 } |
| 118 } | 126 } |
| 119 | 127 |
| 120 void BufferQueue::FreeAllSurfaces() { | 128 void BufferQueue::FreeAllSurfaces() { |
| 121 FreeSurface(¤t_surface_); | 129 FreeSurface(¤t_surface_); |
| 122 while (!in_flight_surfaces_.empty()) { | 130 while (!in_flight_surfaces_.empty()) { |
| 123 FreeSurface(&in_flight_surfaces_.front()); | 131 FreeSurface(&in_flight_surfaces_.front()); |
| 124 in_flight_surfaces_.pop_front(); | 132 in_flight_surfaces_.pop_front(); |
| 125 } | 133 } |
| 134 while (!display_queue_surfaces_.empty()) { | |
| 135 FreeSurface(&display_queue_surfaces_.front()); | |
| 136 display_queue_surfaces_.pop_front(); | |
| 137 } | |
| 126 for (size_t i = 0; i < available_surfaces_.size(); i++) | 138 for (size_t i = 0; i < available_surfaces_.size(); i++) |
| 127 FreeSurface(&available_surfaces_[i]); | 139 FreeSurface(&available_surfaces_[i]); |
| 128 available_surfaces_.clear(); | 140 available_surfaces_.clear(); |
| 129 } | 141 } |
| 130 | 142 |
| 131 void BufferQueue::FreeSurface(AllocatedSurface* surface) { | 143 void BufferQueue::FreeSurface(AllocatedSurface* surface) { |
| 132 if (surface->texture) { | 144 if (surface->texture) { |
| 133 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); | 145 gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); |
| 134 gl->BindTexture(GL_TEXTURE_2D, surface->texture); | 146 gl->BindTexture(GL_TEXTURE_2D, surface->texture); |
| 135 gl->ReleaseTexImage2DCHROMIUM(GL_TEXTURE_2D, surface->image); | 147 gl->ReleaseTexImage2DCHROMIUM(GL_TEXTURE_2D, surface->image); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 167 gl->DeleteTextures(1, &texture); | 179 gl->DeleteTextures(1, &texture); |
| 168 return AllocatedSurface(); | 180 return AllocatedSurface(); |
| 169 } | 181 } |
| 170 allocated_count_++; | 182 allocated_count_++; |
| 171 gl->BindTexture(GL_TEXTURE_2D, texture); | 183 gl->BindTexture(GL_TEXTURE_2D, texture); |
| 172 gl->BindTexImage2DCHROMIUM(GL_TEXTURE_2D, id); | 184 gl->BindTexImage2DCHROMIUM(GL_TEXTURE_2D, id); |
| 173 return AllocatedSurface(texture, id, gfx::Rect(size_)); | 185 return AllocatedSurface(texture, id, gfx::Rect(size_)); |
| 174 } | 186 } |
| 175 | 187 |
| 176 } // namespace content | 188 } // namespace content |
| OLD | NEW |