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 "components/display_compositor/buffer_queue.h" | 5 #include "components/display_compositor/buffer_queue.h" |
6 | 6 |
7 #include "base/containers/adapters.h" | 7 #include "base/containers/adapters.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "components/display_compositor/gl_helper.h" | 10 #include "components/display_compositor/gl_helper.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 if (current_surface_) { | 60 if (current_surface_) { |
61 gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, | 61 gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, |
62 texture_target_, current_surface_->texture, 0); | 62 texture_target_, current_surface_->texture, 0); |
63 if (current_surface_->stencil) { | 63 if (current_surface_->stencil) { |
64 gl_->FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, | 64 gl_->FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, |
65 GL_RENDERBUFFER, current_surface_->stencil); | 65 GL_RENDERBUFFER, current_surface_->stencil); |
66 } | 66 } |
67 } | 67 } |
68 } | 68 } |
69 | 69 |
| 70 bool BufferQueue::CanPartialDraw(const gfx::Rect& damage) { |
| 71 if (current_surface_) |
| 72 return damage.Contains(current_surface_->damage); |
| 73 if (!available_surfaces_.empty()) |
| 74 return damage.Contains(available_surfaces_.back()->damage); |
| 75 return false; |
| 76 } |
| 77 |
70 void BufferQueue::CopyBufferDamage(int texture, | 78 void BufferQueue::CopyBufferDamage(int texture, |
71 int source_texture, | 79 int source_texture, |
72 const gfx::Rect& new_damage, | 80 const gfx::Rect& new_damage, |
73 const gfx::Rect& old_damage) { | 81 const gfx::Rect& old_damage) { |
74 gl_helper_->CopySubBufferDamage(texture_target_, texture, source_texture, | 82 gl_helper_->CopySubBufferDamage(texture_target_, texture, source_texture, |
75 SkRegion(gfx::RectToSkIRect(new_damage)), | 83 SkRegion(gfx::RectToSkIRect(new_damage)), |
76 SkRegion(gfx::RectToSkIRect(old_damage))); | 84 SkRegion(gfx::RectToSkIRect(old_damage))); |
77 } | 85 } |
78 | 86 |
79 void BufferQueue::UpdateBufferDamage(const gfx::Rect& damage) { | 87 void BufferQueue::UpdateBufferDamage(const gfx::Rect& damage) { |
80 if (displayed_surface_) | 88 if (displayed_surface_) |
81 displayed_surface_->damage.Union(damage); | 89 displayed_surface_->damage.Union(damage); |
82 for (auto& surface : available_surfaces_) | 90 for (auto& surface : available_surfaces_) |
83 surface->damage.Union(damage); | 91 surface->damage.Union(damage); |
84 for (auto& surface : in_flight_surfaces_) { | 92 for (auto& surface : in_flight_surfaces_) { |
85 if (surface) | 93 if (surface) |
86 surface->damage.Union(damage); | 94 surface->damage.Union(damage); |
87 } | 95 } |
88 } | 96 } |
89 | 97 |
90 void BufferQueue::SwapBuffers(const gfx::Rect& damage) { | 98 void BufferQueue::SwapBuffers(const gfx::Rect& damage) { |
91 if (current_surface_) { | 99 if (current_surface_) { |
92 if (damage != gfx::Rect(size_)) { | 100 if (!damage.Contains(current_surface_->damage)) { |
93 // Copy damage from the most recently swapped buffer. In the event that | 101 // Copy damage from the most recently swapped buffer. In the event that |
94 // the buffer was destroyed and failed to recreate, pick from the most | 102 // the buffer was destroyed and failed to recreate, pick from the most |
95 // recently available buffer. | 103 // recently available buffer. |
96 uint32_t texture_id = 0; | 104 uint32_t texture_id = 0; |
97 for (auto& surface : base::Reversed(in_flight_surfaces_)) { | 105 for (auto& surface : base::Reversed(in_flight_surfaces_)) { |
98 if (surface) { | 106 if (surface) { |
99 texture_id = surface->texture; | 107 texture_id = surface->texture; |
100 break; | 108 break; |
101 } | 109 } |
102 } | 110 } |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 texture(texture), | 282 texture(texture), |
275 image(image), | 283 image(image), |
276 stencil(stencil), | 284 stencil(stencil), |
277 damage(rect) {} | 285 damage(rect) {} |
278 | 286 |
279 BufferQueue::AllocatedSurface::~AllocatedSurface() { | 287 BufferQueue::AllocatedSurface::~AllocatedSurface() { |
280 buffer_queue->FreeSurfaceResources(this); | 288 buffer_queue->FreeSurfaceResources(this); |
281 } | 289 } |
282 | 290 |
283 } // namespace display_compositor | 291 } // namespace display_compositor |
OLD | NEW |