| 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 3214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3225 if (overlay_resource_pool_) { | 3225 if (overlay_resource_pool_) { |
| 3226 overlay_resource_pool_->CheckBusyResources(); | 3226 overlay_resource_pool_->CheckBusyResources(); |
| 3227 } | 3227 } |
| 3228 | 3228 |
| 3229 scoped_refptr<DCLayerOverlaySharedState> shared_state; | 3229 scoped_refptr<DCLayerOverlaySharedState> shared_state; |
| 3230 size_t copied_render_pass_count = 0; | 3230 size_t copied_render_pass_count = 0; |
| 3231 for (const DCLayerOverlay& dc_layer_overlay : | 3231 for (const DCLayerOverlay& dc_layer_overlay : |
| 3232 current_frame()->dc_layer_overlay_list) { | 3232 current_frame()->dc_layer_overlay_list) { |
| 3233 DCHECK(!dc_layer_overlay.rpdq); | 3233 DCHECK(!dc_layer_overlay.rpdq); |
| 3234 | 3234 |
| 3235 unsigned texture_id = 0; | 3235 int i = 0; |
| 3236 unsigned texture_ids[DrawQuad::Resources::kMaxResourceIdCount] = {}; |
| 3237 int ids_to_send = 0; |
| 3238 |
| 3236 for (const auto& contents_resource_id : dc_layer_overlay.resources) { | 3239 for (const auto& contents_resource_id : dc_layer_overlay.resources) { |
| 3237 if (contents_resource_id) { | 3240 if (contents_resource_id) { |
| 3238 pending_overlay_resources_.push_back( | 3241 pending_overlay_resources_.push_back( |
| 3239 base::MakeUnique<ResourceProvider::ScopedReadLockGL>( | 3242 base::MakeUnique<ResourceProvider::ScopedReadLockGL>( |
| 3240 resource_provider_, contents_resource_id)); | 3243 resource_provider_, contents_resource_id)); |
| 3241 if (!texture_id) | 3244 texture_ids[i] = pending_overlay_resources_.back()->texture_id(); |
| 3242 texture_id = pending_overlay_resources_.back()->texture_id(); | 3245 ids_to_send = i + 1; |
| 3243 } | 3246 } |
| 3247 i++; |
| 3244 } | 3248 } |
| 3245 GLfloat contents_rect[4] = { | 3249 GLfloat contents_rect[4] = { |
| 3246 dc_layer_overlay.contents_rect.x(), dc_layer_overlay.contents_rect.y(), | 3250 dc_layer_overlay.contents_rect.x(), dc_layer_overlay.contents_rect.y(), |
| 3247 dc_layer_overlay.contents_rect.width(), | 3251 dc_layer_overlay.contents_rect.width(), |
| 3248 dc_layer_overlay.contents_rect.height(), | 3252 dc_layer_overlay.contents_rect.height(), |
| 3249 }; | 3253 }; |
| 3250 GLfloat bounds_rect[4] = { | 3254 GLfloat bounds_rect[4] = { |
| 3251 dc_layer_overlay.bounds_rect.x(), dc_layer_overlay.bounds_rect.y(), | 3255 dc_layer_overlay.bounds_rect.x(), dc_layer_overlay.bounds_rect.y(), |
| 3252 dc_layer_overlay.bounds_rect.width(), | 3256 dc_layer_overlay.bounds_rect.width(), |
| 3253 dc_layer_overlay.bounds_rect.height(), | 3257 dc_layer_overlay.bounds_rect.height(), |
| 3254 }; | 3258 }; |
| 3255 GLboolean is_clipped = dc_layer_overlay.shared_state->is_clipped; | 3259 GLboolean is_clipped = dc_layer_overlay.shared_state->is_clipped; |
| 3256 GLfloat clip_rect[4] = {dc_layer_overlay.shared_state->clip_rect.x(), | 3260 GLfloat clip_rect[4] = {dc_layer_overlay.shared_state->clip_rect.x(), |
| 3257 dc_layer_overlay.shared_state->clip_rect.y(), | 3261 dc_layer_overlay.shared_state->clip_rect.y(), |
| 3258 dc_layer_overlay.shared_state->clip_rect.width(), | 3262 dc_layer_overlay.shared_state->clip_rect.width(), |
| 3259 dc_layer_overlay.shared_state->clip_rect.height()}; | 3263 dc_layer_overlay.shared_state->clip_rect.height()}; |
| 3260 GLint z_order = dc_layer_overlay.shared_state->z_order; | 3264 GLint z_order = dc_layer_overlay.shared_state->z_order; |
| 3261 GLfloat transform[16]; | 3265 GLfloat transform[16]; |
| 3262 dc_layer_overlay.shared_state->transform.asColMajorf(transform); | 3266 dc_layer_overlay.shared_state->transform.asColMajorf(transform); |
| 3263 unsigned filter = dc_layer_overlay.filter; | 3267 unsigned filter = dc_layer_overlay.filter; |
| 3264 | 3268 |
| 3265 if (dc_layer_overlay.shared_state != shared_state) { | 3269 if (dc_layer_overlay.shared_state != shared_state) { |
| 3266 shared_state = dc_layer_overlay.shared_state; | 3270 shared_state = dc_layer_overlay.shared_state; |
| 3267 gl_->ScheduleDCLayerSharedStateCHROMIUM( | 3271 gl_->ScheduleDCLayerSharedStateCHROMIUM( |
| 3268 dc_layer_overlay.shared_state->opacity, is_clipped, clip_rect, | 3272 dc_layer_overlay.shared_state->opacity, is_clipped, clip_rect, |
| 3269 z_order, transform); | 3273 z_order, transform); |
| 3270 } | 3274 } |
| 3271 gl_->ScheduleDCLayerCHROMIUM( | 3275 gl_->ScheduleDCLayerCHROMIUM(ids_to_send, texture_ids, contents_rect, |
| 3272 texture_id, contents_rect, dc_layer_overlay.background_color, | 3276 dc_layer_overlay.background_color, |
| 3273 dc_layer_overlay.edge_aa_mask, bounds_rect, filter); | 3277 dc_layer_overlay.edge_aa_mask, bounds_rect, |
| 3278 filter); |
| 3274 } | 3279 } |
| 3275 | 3280 |
| 3276 // Take the number of copied render passes in this frame, and use 3 times that | 3281 // Take the number of copied render passes in this frame, and use 3 times that |
| 3277 // amount as the cache limit. | 3282 // amount as the cache limit. |
| 3278 if (overlay_resource_pool_) { | 3283 if (overlay_resource_pool_) { |
| 3279 overlay_resource_pool_->SetResourceUsageLimits( | 3284 overlay_resource_pool_->SetResourceUsageLimits( |
| 3280 std::numeric_limits<std::size_t>::max(), copied_render_pass_count * 5); | 3285 std::numeric_limits<std::size_t>::max(), copied_render_pass_count * 5); |
| 3281 } | 3286 } |
| 3282 } | 3287 } |
| 3283 | 3288 |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3603 return; | 3608 return; |
| 3604 | 3609 |
| 3605 // Report GPU overdraw as a percentage of |max_result|. | 3610 // Report GPU overdraw as a percentage of |max_result|. |
| 3606 TRACE_COUNTER1( | 3611 TRACE_COUNTER1( |
| 3607 TRACE_DISABLED_BY_DEFAULT("cc.debug.overdraw"), "GPU Overdraw", | 3612 TRACE_DISABLED_BY_DEFAULT("cc.debug.overdraw"), "GPU Overdraw", |
| 3608 (std::accumulate(overdraw->begin(), overdraw->end(), 0) * 100) / | 3613 (std::accumulate(overdraw->begin(), overdraw->end(), 0) * 100) / |
| 3609 max_result); | 3614 max_result); |
| 3610 } | 3615 } |
| 3611 | 3616 |
| 3612 } // namespace cc | 3617 } // namespace cc |
| OLD | NEW |