| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "cc/output/delegating_renderer.h" | 5 #include "cc/output/delegating_renderer.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/debug/trace_event.h" | 11 #include "base/debug/trace_event.h" |
| 12 #include "base/strings/string_split.h" | 12 #include "base/strings/string_split.h" |
| 13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 15 #include "cc/output/compositor_frame_ack.h" | 15 #include "cc/output/compositor_frame_ack.h" |
| 16 #include "cc/quads/checkerboard_draw_quad.h" | 16 #include "cc/quads/checkerboard_draw_quad.h" |
| 17 #include "cc/quads/debug_border_draw_quad.h" | 17 #include "cc/quads/debug_border_draw_quad.h" |
| 18 #include "cc/quads/render_pass.h" | 18 #include "cc/quads/render_pass.h" |
| 19 #include "cc/quads/render_pass_draw_quad.h" | 19 #include "cc/quads/render_pass_draw_quad.h" |
| 20 #include "cc/quads/solid_color_draw_quad.h" | 20 #include "cc/quads/solid_color_draw_quad.h" |
| 21 #include "cc/quads/texture_draw_quad.h" | 21 #include "cc/quads/texture_draw_quad.h" |
| 22 #include "cc/quads/tile_draw_quad.h" | 22 #include "cc/quads/tile_draw_quad.h" |
| 23 #include "cc/quads/yuv_video_draw_quad.h" | 23 #include "cc/quads/yuv_video_draw_quad.h" |
| 24 #include "cc/resources/resource_provider.h" | 24 #include "cc/resources/resource_provider.h" |
| 25 #include "gpu/command_buffer/client/context_support.h" | 25 #include "gpu/command_buffer/client/context_support.h" |
| 26 #include "gpu/command_buffer/client/gles2_interface.h" |
| 26 #include "gpu/command_buffer/common/gpu_memory_allocation.h" | 27 #include "gpu/command_buffer/common/gpu_memory_allocation.h" |
| 27 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" | |
| 28 #include "third_party/khronos/GLES2/gl2ext.h" | 28 #include "third_party/khronos/GLES2/gl2ext.h" |
| 29 | 29 |
| 30 using blink::WebGraphicsContext3D; | 30 using blink::WebGraphicsContext3D; |
| 31 | 31 |
| 32 namespace cc { | 32 namespace cc { |
| 33 | 33 |
| 34 scoped_ptr<DelegatingRenderer> DelegatingRenderer::Create( | 34 scoped_ptr<DelegatingRenderer> DelegatingRenderer::Create( |
| 35 RendererClient* client, | 35 RendererClient* client, |
| 36 const LayerTreeSettings* settings, | 36 const LayerTreeSettings* settings, |
| 37 OutputSurface* output_surface, | 37 OutputSurface* output_surface, |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 void DelegatingRenderer::SetVisible(bool visible) { | 148 void DelegatingRenderer::SetVisible(bool visible) { |
| 149 if (visible == visible_) | 149 if (visible == visible_) |
| 150 return; | 150 return; |
| 151 | 151 |
| 152 visible_ = visible; | 152 visible_ = visible; |
| 153 ContextProvider* context_provider = output_surface_->context_provider(); | 153 ContextProvider* context_provider = output_surface_->context_provider(); |
| 154 if (!visible_) { | 154 if (!visible_) { |
| 155 TRACE_EVENT0("cc", "DelegatingRenderer::SetVisible dropping resources"); | 155 TRACE_EVENT0("cc", "DelegatingRenderer::SetVisible dropping resources"); |
| 156 resource_provider_->ReleaseCachedData(); | 156 resource_provider_->ReleaseCachedData(); |
| 157 if (context_provider) | 157 if (context_provider) |
| 158 context_provider->Context3d()->flush(); | 158 context_provider->ContextGL()->Flush(); |
| 159 } | 159 } |
| 160 // We loop visibility to the GPU process, since that's what manages memory. | 160 // We loop visibility to the GPU process, since that's what manages memory. |
| 161 // That will allow it to feed us with memory allocations that we can act | 161 // That will allow it to feed us with memory allocations that we can act |
| 162 // upon. | 162 // upon. |
| 163 DCHECK(context_provider); | 163 DCHECK(context_provider); |
| 164 context_provider->ContextSupport()->SetSurfaceVisible(visible); | 164 context_provider->ContextSupport()->SetSurfaceVisible(visible); |
| 165 } | 165 } |
| 166 | 166 |
| 167 void DelegatingRenderer::SendManagedMemoryStats(size_t bytes_visible, | 167 void DelegatingRenderer::SendManagedMemoryStats(size_t bytes_visible, |
| 168 size_t bytes_visible_and_nearby, | 168 size_t bytes_visible_and_nearby, |
| 169 size_t bytes_allocated) { | 169 size_t bytes_allocated) { |
| 170 ContextProvider* context_provider = output_surface_->context_provider(); | 170 ContextProvider* context_provider = output_surface_->context_provider(); |
| 171 if (!context_provider) { | 171 if (!context_provider) { |
| 172 // TODO(piman): software path. | 172 // TODO(piman): software path. |
| 173 NOTIMPLEMENTED(); | 173 NOTIMPLEMENTED(); |
| 174 return; | 174 return; |
| 175 } | 175 } |
| 176 gpu::ManagedMemoryStats stats; | 176 gpu::ManagedMemoryStats stats; |
| 177 stats.bytes_required = bytes_visible; | 177 stats.bytes_required = bytes_visible; |
| 178 stats.bytes_nice_to_have = bytes_visible_and_nearby; | 178 stats.bytes_nice_to_have = bytes_visible_and_nearby; |
| 179 stats.bytes_allocated = bytes_allocated; | 179 stats.bytes_allocated = bytes_allocated; |
| 180 stats.backbuffer_requested = false; | 180 stats.backbuffer_requested = false; |
| 181 | 181 |
| 182 context_provider->ContextSupport()->SendManagedMemoryStats(stats); | 182 context_provider->ContextSupport()->SendManagedMemoryStats(stats); |
| 183 } | 183 } |
| 184 | 184 |
| 185 } // namespace cc | 185 } // namespace cc |
| OLD | NEW |