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/browser/gpu/browser_gpu_memory_buffer_manager.h" | 8 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" |
9 #include "content/common/gpu/client/context_provider_command_buffer.h" | 9 #include "content/common/gpu/client/context_provider_command_buffer.h" |
10 #include "content/common/gpu/client/gl_helper.h" | 10 #include "content/common/gpu/client/gl_helper.h" |
11 #include "gpu/GLES2/gl2extchromium.h" | 11 #include "gpu/GLES2/gl2extchromium.h" |
12 #include "gpu/command_buffer/client/gles2_interface.h" | 12 #include "gpu/command_buffer/client/gles2_interface.h" |
13 #include "gpu/command_buffer/service/image_factory.h" | 13 #include "gpu/command_buffer/service/image_factory.h" |
14 #include "third_party/skia/include/core/SkRect.h" | 14 #include "third_party/skia/include/core/SkRect.h" |
15 #include "third_party/skia/include/core/SkRegion.h" | 15 #include "third_party/skia/include/core/SkRegion.h" |
16 #include "ui/gfx/gpu_memory_buffer.h" | 16 #include "ui/gfx/gpu_memory_buffer.h" |
| 17 #include "ui/gfx/skia_util.h" |
17 | 18 |
18 namespace content { | 19 namespace content { |
19 | 20 |
20 BufferQueue::BufferQueue( | 21 BufferQueue::BufferQueue( |
21 scoped_refptr<cc::ContextProvider> context_provider, | 22 scoped_refptr<cc::ContextProvider> context_provider, |
22 unsigned int texture_target, | 23 unsigned int texture_target, |
23 unsigned int internalformat, | 24 unsigned int internalformat, |
24 GLHelper* gl_helper, | 25 GLHelper* gl_helper, |
25 BrowserGpuMemoryBufferManager* gpu_memory_buffer_manager, | 26 BrowserGpuMemoryBufferManager* gpu_memory_buffer_manager, |
26 int surface_id) | 27 int surface_id) |
(...skipping 27 matching lines...) Expand all Loading... |
54 current_surface_ = GetNextSurface(); | 55 current_surface_ = GetNextSurface(); |
55 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, | 56 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, |
56 texture_target_, current_surface_.texture, 0); | 57 texture_target_, current_surface_.texture, 0); |
57 } | 58 } |
58 } | 59 } |
59 | 60 |
60 void BufferQueue::CopyBufferDamage(int texture, | 61 void BufferQueue::CopyBufferDamage(int texture, |
61 int source_texture, | 62 int source_texture, |
62 const gfx::Rect& new_damage, | 63 const gfx::Rect& new_damage, |
63 const gfx::Rect& old_damage) { | 64 const gfx::Rect& old_damage) { |
| 65 gfx::Rect new_damage_mutable = new_damage; |
| 66 gfx::Rect old_damage_mutable = old_damage; |
| 67 #if defined(ARCH_CPU_ARM_FAMILY) |
| 68 // TODO(dnicoara): Remove ARM workaround once partial swap is enabled. |
| 69 new_damage_mutable = gfx::Rect(size_); |
| 70 old_damage_mutable = gfx::Rect(); |
| 71 #endif |
| 72 |
64 gl_helper_->CopySubBufferDamage( | 73 gl_helper_->CopySubBufferDamage( |
65 texture_target_, texture, source_texture, | 74 texture_target_, texture, source_texture, |
66 SkRegion(SkIRect::MakeXYWH(new_damage.x(), new_damage.y(), | 75 SkRegion(gfx::RectToSkIRect(new_damage_mutable)), |
67 new_damage.width(), new_damage.height())), | 76 SkRegion(gfx::RectToSkIRect(old_damage_mutable))); |
68 SkRegion(SkIRect::MakeXYWH(old_damage.x(), old_damage.y(), | |
69 old_damage.width(), old_damage.height()))); | |
70 } | 77 } |
71 | 78 |
72 void BufferQueue::UpdateBufferDamage(const gfx::Rect& damage) { | 79 void BufferQueue::UpdateBufferDamage(const gfx::Rect& damage) { |
73 displayed_surface_.damage.Union(damage); | 80 displayed_surface_.damage.Union(damage); |
74 for (size_t i = 0; i < available_surfaces_.size(); i++) | 81 for (size_t i = 0; i < available_surfaces_.size(); i++) |
75 available_surfaces_[i].damage.Union(damage); | 82 available_surfaces_[i].damage.Union(damage); |
76 | 83 |
77 for (std::deque<AllocatedSurface>::iterator it = | 84 for (std::deque<AllocatedSurface>::iterator it = |
78 in_flight_surfaces_.begin(); | 85 in_flight_surfaces_.begin(); |
79 it != in_flight_surfaces_.end(); | 86 it != in_flight_surfaces_.end(); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 gl->DeleteTextures(1, &texture); | 241 gl->DeleteTextures(1, &texture); |
235 return AllocatedSurface(); | 242 return AllocatedSurface(); |
236 } | 243 } |
237 allocated_count_++; | 244 allocated_count_++; |
238 gl->BindTexture(texture_target_, texture); | 245 gl->BindTexture(texture_target_, texture); |
239 gl->BindTexImage2DCHROMIUM(texture_target_, id); | 246 gl->BindTexImage2DCHROMIUM(texture_target_, id); |
240 return AllocatedSurface(texture, id, gfx::Rect(size_)); | 247 return AllocatedSurface(texture, id, gfx::Rect(size_)); |
241 } | 248 } |
242 | 249 |
243 } // namespace content | 250 } // namespace content |
OLD | NEW |