OLD | NEW |
1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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/gl_renderer.h" | 5 #include "cc/output/gl_renderer.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 2424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2435 swap_buffer_rect_.Union(current_frame()->root_damage_rect); | 2435 swap_buffer_rect_.Union(current_frame()->root_damage_rect); |
2436 if (overdraw_feedback_) | 2436 if (overdraw_feedback_) |
2437 FlushOverdrawFeedback(swap_buffer_rect_); | 2437 FlushOverdrawFeedback(swap_buffer_rect_); |
2438 | 2438 |
2439 current_framebuffer_lock_ = nullptr; | 2439 current_framebuffer_lock_ = nullptr; |
2440 | 2440 |
2441 gl_->Disable(GL_BLEND); | 2441 gl_->Disable(GL_BLEND); |
2442 blend_shadow_ = false; | 2442 blend_shadow_ = false; |
2443 | 2443 |
2444 ScheduleCALayers(); | 2444 ScheduleCALayers(); |
| 2445 ScheduleDCLayers(); |
2445 ScheduleOverlays(); | 2446 ScheduleOverlays(); |
2446 } | 2447 } |
2447 | 2448 |
2448 void GLRenderer::FinishDrawingQuadList() { | 2449 void GLRenderer::FinishDrawingQuadList() { |
2449 FlushTextureQuadCache(SHARED_BINDING); | 2450 FlushTextureQuadCache(SHARED_BINDING); |
2450 } | 2451 } |
2451 | 2452 |
2452 bool GLRenderer::FlippedFramebuffer() const { | 2453 bool GLRenderer::FlippedFramebuffer() const { |
2453 if (force_drawing_frame_framebuffer_unflipped_) | 2454 if (force_drawing_frame_framebuffer_unflipped_) |
2454 return false; | 2455 return false; |
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3170 } | 3171 } |
3171 | 3172 |
3172 // Take the number of copied render passes in this frame, and use 3 times that | 3173 // Take the number of copied render passes in this frame, and use 3 times that |
3173 // amount as the cache limit. | 3174 // amount as the cache limit. |
3174 if (overlay_resource_pool_) { | 3175 if (overlay_resource_pool_) { |
3175 overlay_resource_pool_->SetResourceUsageLimits( | 3176 overlay_resource_pool_->SetResourceUsageLimits( |
3176 std::numeric_limits<std::size_t>::max(), copied_render_pass_count * 5); | 3177 std::numeric_limits<std::size_t>::max(), copied_render_pass_count * 5); |
3177 } | 3178 } |
3178 } | 3179 } |
3179 | 3180 |
| 3181 void GLRenderer::ScheduleDCLayers() { |
| 3182 if (overlay_resource_pool_) { |
| 3183 overlay_resource_pool_->CheckBusyResources(); |
| 3184 } |
| 3185 |
| 3186 scoped_refptr<DCLayerOverlaySharedState> shared_state; |
| 3187 size_t copied_render_pass_count = 0; |
| 3188 for (const DCLayerOverlay& dc_layer_overlay : |
| 3189 current_frame()->dc_layer_overlay_list) { |
| 3190 DCHECK(!dc_layer_overlay.rpdq); |
| 3191 |
| 3192 ResourceId contents_resource_id = dc_layer_overlay.contents_resource_id; |
| 3193 unsigned texture_id = 0; |
| 3194 if (contents_resource_id) { |
| 3195 pending_overlay_resources_.push_back( |
| 3196 base::MakeUnique<ResourceProvider::ScopedReadLockGL>( |
| 3197 resource_provider_, contents_resource_id)); |
| 3198 texture_id = pending_overlay_resources_.back()->texture_id(); |
| 3199 } |
| 3200 GLfloat contents_rect[4] = { |
| 3201 dc_layer_overlay.contents_rect.x(), dc_layer_overlay.contents_rect.y(), |
| 3202 dc_layer_overlay.contents_rect.width(), |
| 3203 dc_layer_overlay.contents_rect.height(), |
| 3204 }; |
| 3205 GLfloat bounds_rect[4] = { |
| 3206 dc_layer_overlay.bounds_rect.x(), dc_layer_overlay.bounds_rect.y(), |
| 3207 dc_layer_overlay.bounds_rect.width(), |
| 3208 dc_layer_overlay.bounds_rect.height(), |
| 3209 }; |
| 3210 GLboolean is_clipped = dc_layer_overlay.shared_state->is_clipped; |
| 3211 GLfloat clip_rect[4] = {dc_layer_overlay.shared_state->clip_rect.x(), |
| 3212 dc_layer_overlay.shared_state->clip_rect.y(), |
| 3213 dc_layer_overlay.shared_state->clip_rect.width(), |
| 3214 dc_layer_overlay.shared_state->clip_rect.height()}; |
| 3215 GLint z_order = dc_layer_overlay.shared_state->z_order; |
| 3216 GLfloat transform[16]; |
| 3217 dc_layer_overlay.shared_state->transform.asColMajorf(transform); |
| 3218 unsigned filter = dc_layer_overlay.filter; |
| 3219 |
| 3220 if (dc_layer_overlay.shared_state != shared_state) { |
| 3221 shared_state = dc_layer_overlay.shared_state; |
| 3222 gl_->ScheduleDCLayerSharedStateCHROMIUM( |
| 3223 dc_layer_overlay.shared_state->opacity, is_clipped, clip_rect, |
| 3224 z_order, transform); |
| 3225 } |
| 3226 gl_->ScheduleDCLayerCHROMIUM( |
| 3227 texture_id, contents_rect, dc_layer_overlay.background_color, |
| 3228 dc_layer_overlay.edge_aa_mask, bounds_rect, filter); |
| 3229 } |
| 3230 |
| 3231 // Take the number of copied render passes in this frame, and use 3 times that |
| 3232 // amount as the cache limit. |
| 3233 if (overlay_resource_pool_) { |
| 3234 overlay_resource_pool_->SetResourceUsageLimits( |
| 3235 std::numeric_limits<std::size_t>::max(), copied_render_pass_count * 5); |
| 3236 } |
| 3237 } |
| 3238 |
3180 void GLRenderer::ScheduleOverlays() { | 3239 void GLRenderer::ScheduleOverlays() { |
3181 if (current_frame()->overlay_list.empty()) | 3240 if (current_frame()->overlay_list.empty()) |
3182 return; | 3241 return; |
3183 | 3242 |
3184 OverlayCandidateList& overlays = current_frame()->overlay_list; | 3243 OverlayCandidateList& overlays = current_frame()->overlay_list; |
3185 for (const OverlayCandidate& overlay : overlays) { | 3244 for (const OverlayCandidate& overlay : overlays) { |
3186 unsigned texture_id = 0; | 3245 unsigned texture_id = 0; |
3187 if (overlay.use_output_surface_for_resource) { | 3246 if (overlay.use_output_surface_for_resource) { |
3188 texture_id = output_surface_->GetOverlayTextureId(); | 3247 texture_id = output_surface_->GetOverlayTextureId(); |
3189 DCHECK(texture_id || IsContextLost()); | 3248 DCHECK(texture_id || IsContextLost()); |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3498 return; | 3557 return; |
3499 | 3558 |
3500 // Report GPU overdraw as a percentage of |max_result|. | 3559 // Report GPU overdraw as a percentage of |max_result|. |
3501 TRACE_COUNTER1( | 3560 TRACE_COUNTER1( |
3502 TRACE_DISABLED_BY_DEFAULT("cc.debug.overdraw"), "GPU Overdraw", | 3561 TRACE_DISABLED_BY_DEFAULT("cc.debug.overdraw"), "GPU Overdraw", |
3503 (std::accumulate(overdraw->begin(), overdraw->end(), 0) * 100) / | 3562 (std::accumulate(overdraw->begin(), overdraw->end(), 0) * 100) / |
3504 max_result); | 3563 max_result); |
3505 } | 3564 } |
3506 | 3565 |
3507 } // namespace cc | 3566 } // namespace cc |
OLD | NEW |