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; | |
31 | 30 |
32 namespace cc { | 31 namespace cc { |
33 | 32 |
34 scoped_ptr<DelegatingRenderer> DelegatingRenderer::Create( | 33 scoped_ptr<DelegatingRenderer> DelegatingRenderer::Create( |
35 RendererClient* client, | 34 RendererClient* client, |
36 const LayerTreeSettings* settings, | 35 const LayerTreeSettings* settings, |
37 OutputSurface* output_surface, | 36 OutputSurface* output_surface, |
38 ResourceProvider* resource_provider) { | 37 ResourceProvider* resource_provider) { |
39 scoped_ptr<DelegatingRenderer> renderer(new DelegatingRenderer( | 38 scoped_ptr<DelegatingRenderer> renderer(new DelegatingRenderer( |
40 client, settings, output_surface, resource_provider)); | 39 client, settings, output_surface, resource_provider)); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 void DelegatingRenderer::SetVisible(bool visible) { | 147 void DelegatingRenderer::SetVisible(bool visible) { |
149 if (visible == visible_) | 148 if (visible == visible_) |
150 return; | 149 return; |
151 | 150 |
152 visible_ = visible; | 151 visible_ = visible; |
153 ContextProvider* context_provider = output_surface_->context_provider(); | 152 ContextProvider* context_provider = output_surface_->context_provider(); |
154 if (!visible_) { | 153 if (!visible_) { |
155 TRACE_EVENT0("cc", "DelegatingRenderer::SetVisible dropping resources"); | 154 TRACE_EVENT0("cc", "DelegatingRenderer::SetVisible dropping resources"); |
156 resource_provider_->ReleaseCachedData(); | 155 resource_provider_->ReleaseCachedData(); |
157 if (context_provider) | 156 if (context_provider) |
158 context_provider->Context3d()->flush(); | 157 context_provider->ContextGL()->Flush(); |
159 } | 158 } |
160 // We loop visibility to the GPU process, since that's what manages memory. | 159 // 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 | 160 // That will allow it to feed us with memory allocations that we can act |
162 // upon. | 161 // upon. |
163 DCHECK(context_provider); | 162 DCHECK(context_provider); |
164 context_provider->ContextSupport()->SetSurfaceVisible(visible); | 163 context_provider->ContextSupport()->SetSurfaceVisible(visible); |
165 } | 164 } |
166 | 165 |
167 void DelegatingRenderer::SendManagedMemoryStats(size_t bytes_visible, | 166 void DelegatingRenderer::SendManagedMemoryStats(size_t bytes_visible, |
168 size_t bytes_visible_and_nearby, | 167 size_t bytes_visible_and_nearby, |
169 size_t bytes_allocated) { | 168 size_t bytes_allocated) { |
170 ContextProvider* context_provider = output_surface_->context_provider(); | 169 ContextProvider* context_provider = output_surface_->context_provider(); |
171 if (!context_provider) { | 170 if (!context_provider) { |
172 // TODO(piman): software path. | 171 // TODO(piman): software path. |
173 NOTIMPLEMENTED(); | 172 NOTIMPLEMENTED(); |
174 return; | 173 return; |
175 } | 174 } |
176 gpu::ManagedMemoryStats stats; | 175 gpu::ManagedMemoryStats stats; |
177 stats.bytes_required = bytes_visible; | 176 stats.bytes_required = bytes_visible; |
178 stats.bytes_nice_to_have = bytes_visible_and_nearby; | 177 stats.bytes_nice_to_have = bytes_visible_and_nearby; |
179 stats.bytes_allocated = bytes_allocated; | 178 stats.bytes_allocated = bytes_allocated; |
180 stats.backbuffer_requested = false; | 179 stats.backbuffer_requested = false; |
181 | 180 |
182 context_provider->ContextSupport()->SendManagedMemoryStats(stats); | 181 context_provider->ContextSupport()->SendManagedMemoryStats(stats); |
183 } | 182 } |
184 | 183 |
185 } // namespace cc | 184 } // namespace cc |
OLD | NEW |