| 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 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 } | 522 } |
| 523 | 523 |
| 524 while (!pending_sync_queries_.empty()) { | 524 while (!pending_sync_queries_.empty()) { |
| 525 if (pending_sync_queries_.front()->IsPending()) | 525 if (pending_sync_queries_.front()->IsPending()) |
| 526 break; | 526 break; |
| 527 | 527 |
| 528 available_sync_queries_.push_back(PopFront(&pending_sync_queries_)); | 528 available_sync_queries_.push_back(PopFront(&pending_sync_queries_)); |
| 529 } | 529 } |
| 530 | 530 |
| 531 current_sync_query_ = available_sync_queries_.empty() | 531 current_sync_query_ = available_sync_queries_.empty() |
| 532 ? base::WrapUnique(new SyncQuery(gl_)) | 532 ? base::MakeUnique<SyncQuery>(gl_) |
| 533 : PopFront(&available_sync_queries_); | 533 : PopFront(&available_sync_queries_); |
| 534 | 534 |
| 535 read_lock_fence = current_sync_query_->Begin(); | 535 read_lock_fence = current_sync_query_->Begin(); |
| 536 } else { | 536 } else { |
| 537 read_lock_fence = | 537 read_lock_fence = |
| 538 make_scoped_refptr(new ResourceProvider::SynchronousFence(gl_)); | 538 make_scoped_refptr(new ResourceProvider::SynchronousFence(gl_)); |
| 539 } | 539 } |
| 540 resource_provider_->SetReadLockFence(read_lock_fence.get()); | 540 resource_provider_->SetReadLockFence(read_lock_fence.get()); |
| 541 | 541 |
| 542 // Insert WaitSyncTokenCHROMIUM on quad resources prior to drawing the frame, | 542 // Insert WaitSyncTokenCHROMIUM on quad resources prior to drawing the frame, |
| (...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1252 DCHECK(filter_image_id); | 1252 DCHECK(filter_image_id); |
| 1253 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_)); | 1253 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_)); |
| 1254 gl_->BindTexture(GL_TEXTURE_2D, filter_image_id); | 1254 gl_->BindTexture(GL_TEXTURE_2D, filter_image_id); |
| 1255 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | 1255 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| 1256 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); | 1256 gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
| 1257 | 1257 |
| 1258 params->source_needs_flip = params->filter_image->getTexture()->origin() == | 1258 params->source_needs_flip = params->filter_image->getTexture()->origin() == |
| 1259 kBottomLeft_GrSurfaceOrigin; | 1259 kBottomLeft_GrSurfaceOrigin; |
| 1260 } else { | 1260 } else { |
| 1261 params->contents_resource_lock = | 1261 params->contents_resource_lock = |
| 1262 base::WrapUnique(new ResourceProvider::ScopedSamplerGL( | 1262 base::MakeUnique<ResourceProvider::ScopedSamplerGL>( |
| 1263 resource_provider_, params->contents_texture->id(), GL_LINEAR)); | 1263 resource_provider_, params->contents_texture->id(), GL_LINEAR); |
| 1264 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), | 1264 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), |
| 1265 params->contents_resource_lock->target()); | 1265 params->contents_resource_lock->target()); |
| 1266 params->source_needs_flip = params->flip_texture; | 1266 params->source_needs_flip = params->flip_texture; |
| 1267 } | 1267 } |
| 1268 } | 1268 } |
| 1269 | 1269 |
| 1270 void GLRenderer::UpdateRPDQBlendMode(DrawRenderPassDrawQuadParams* params) { | 1270 void GLRenderer::UpdateRPDQBlendMode(DrawRenderPassDrawQuadParams* params) { |
| 1271 SkXfermode::Mode blend_mode = params->quad->shared_quad_state->blend_mode; | 1271 SkXfermode::Mode blend_mode = params->quad->shared_quad_state->blend_mode; |
| 1272 SetBlendEnabled(!params->use_shaders_for_blending && | 1272 SetBlendEnabled(!params->use_shaders_for_blending && |
| 1273 (params->quad->ShouldDrawWithBlending() || | 1273 (params->quad->ShouldDrawWithBlending() || |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1470 | 1470 |
| 1471 if (params->background_image_id) { | 1471 if (params->background_image_id) { |
| 1472 gl_->ActiveTexture(GL_TEXTURE0 + last_texture_unit); | 1472 gl_->ActiveTexture(GL_TEXTURE0 + last_texture_unit); |
| 1473 gl_->BindTexture(GL_TEXTURE_2D, params->background_image_id); | 1473 gl_->BindTexture(GL_TEXTURE_2D, params->background_image_id); |
| 1474 gl_->ActiveTexture(GL_TEXTURE0); | 1474 gl_->ActiveTexture(GL_TEXTURE0); |
| 1475 if (params->mask_for_background) | 1475 if (params->mask_for_background) |
| 1476 gl_->Uniform1i(locations.original_backdrop, ++last_texture_unit); | 1476 gl_->Uniform1i(locations.original_backdrop, ++last_texture_unit); |
| 1477 } | 1477 } |
| 1478 if (params->background_texture) { | 1478 if (params->background_texture) { |
| 1479 params->shader_background_sampler_lock = | 1479 params->shader_background_sampler_lock = |
| 1480 base::WrapUnique(new ResourceProvider::ScopedSamplerGL( | 1480 base::MakeUnique<ResourceProvider::ScopedSamplerGL>( |
| 1481 resource_provider_, params->background_texture->id(), | 1481 resource_provider_, params->background_texture->id(), |
| 1482 GL_TEXTURE0 + last_texture_unit, GL_LINEAR)); | 1482 GL_TEXTURE0 + last_texture_unit, GL_LINEAR); |
| 1483 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), | 1483 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), |
| 1484 params->shader_background_sampler_lock->target()); | 1484 params->shader_background_sampler_lock->target()); |
| 1485 } | 1485 } |
| 1486 } | 1486 } |
| 1487 | 1487 |
| 1488 SetShaderOpacity(params->quad->shared_quad_state->opacity, locations.alpha); | 1488 SetShaderOpacity(params->quad->shared_quad_state->opacity, locations.alpha); |
| 1489 SetShaderQuadF(params->surface_quad, locations.quad); | 1489 SetShaderQuadF(params->surface_quad, locations.quad); |
| 1490 } | 1490 } |
| 1491 | 1491 |
| 1492 void GLRenderer::DrawRPDQ(const DrawRenderPassDrawQuadParams& params) { | 1492 void GLRenderer::DrawRPDQ(const DrawRenderPassDrawQuadParams& params) { |
| (...skipping 1695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3188 const ScopedResource* texture) { | 3188 const ScopedResource* texture) { |
| 3189 DCHECK(texture->id()); | 3189 DCHECK(texture->id()); |
| 3190 | 3190 |
| 3191 // Explicitly release lock, otherwise we can crash when try to lock | 3191 // Explicitly release lock, otherwise we can crash when try to lock |
| 3192 // same texture again. | 3192 // same texture again. |
| 3193 current_framebuffer_lock_ = nullptr; | 3193 current_framebuffer_lock_ = nullptr; |
| 3194 | 3194 |
| 3195 SetStencilEnabled(false); | 3195 SetStencilEnabled(false); |
| 3196 gl_->BindFramebuffer(GL_FRAMEBUFFER, offscreen_framebuffer_id_); | 3196 gl_->BindFramebuffer(GL_FRAMEBUFFER, offscreen_framebuffer_id_); |
| 3197 current_framebuffer_lock_ = | 3197 current_framebuffer_lock_ = |
| 3198 base::WrapUnique(new ResourceProvider::ScopedWriteLockGL( | 3198 base::MakeUnique<ResourceProvider::ScopedWriteLockGL>( |
| 3199 resource_provider_, texture->id(), false)); | 3199 resource_provider_, texture->id(), false); |
| 3200 current_framebuffer_format_ = texture->format(); | 3200 current_framebuffer_format_ = texture->format(); |
| 3201 unsigned texture_id = current_framebuffer_lock_->texture_id(); | 3201 unsigned texture_id = current_framebuffer_lock_->texture_id(); |
| 3202 gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, | 3202 gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
| 3203 texture_id, 0); | 3203 texture_id, 0); |
| 3204 | 3204 |
| 3205 DCHECK(gl_->CheckFramebufferStatus(GL_FRAMEBUFFER) == | 3205 DCHECK(gl_->CheckFramebufferStatus(GL_FRAMEBUFFER) == |
| 3206 GL_FRAMEBUFFER_COMPLETE || | 3206 GL_FRAMEBUFFER_COMPLETE || |
| 3207 IsContextLost()); | 3207 IsContextLost()); |
| 3208 return true; | 3208 return true; |
| 3209 } | 3209 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 3231 current_window_space_viewport_.height()); | 3231 current_window_space_viewport_.height()); |
| 3232 } | 3232 } |
| 3233 | 3233 |
| 3234 void GLRenderer::InitializeSharedObjects() { | 3234 void GLRenderer::InitializeSharedObjects() { |
| 3235 TRACE_EVENT0("cc", "GLRenderer::InitializeSharedObjects"); | 3235 TRACE_EVENT0("cc", "GLRenderer::InitializeSharedObjects"); |
| 3236 | 3236 |
| 3237 // Create an FBO for doing offscreen rendering. | 3237 // Create an FBO for doing offscreen rendering. |
| 3238 gl_->GenFramebuffers(1, &offscreen_framebuffer_id_); | 3238 gl_->GenFramebuffers(1, &offscreen_framebuffer_id_); |
| 3239 | 3239 |
| 3240 shared_geometry_ = | 3240 shared_geometry_ = |
| 3241 base::WrapUnique(new StaticGeometryBinding(gl_, QuadVertexRect())); | 3241 base::MakeUnique<StaticGeometryBinding>(gl_, QuadVertexRect()); |
| 3242 clipped_geometry_ = base::WrapUnique(new DynamicGeometryBinding(gl_)); | 3242 clipped_geometry_ = base::MakeUnique<DynamicGeometryBinding>(gl_); |
| 3243 } | 3243 } |
| 3244 | 3244 |
| 3245 void GLRenderer::PrepareGeometry(BoundGeometry binding) { | 3245 void GLRenderer::PrepareGeometry(BoundGeometry binding) { |
| 3246 if (binding == bound_geometry_) { | 3246 if (binding == bound_geometry_) { |
| 3247 return; | 3247 return; |
| 3248 } | 3248 } |
| 3249 | 3249 |
| 3250 switch (binding) { | 3250 switch (binding) { |
| 3251 case SHARED_BINDING: | 3251 case SHARED_BINDING: |
| 3252 shared_geometry_->PrepareForDraw(); | 3252 shared_geometry_->PrepareForDraw(); |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3770 ScheduleRenderPassDrawQuad(&ca_layer_overlay, frame); | 3770 ScheduleRenderPassDrawQuad(&ca_layer_overlay, frame); |
| 3771 shared_state = nullptr; | 3771 shared_state = nullptr; |
| 3772 ++copied_render_pass_count; | 3772 ++copied_render_pass_count; |
| 3773 continue; | 3773 continue; |
| 3774 } | 3774 } |
| 3775 | 3775 |
| 3776 ResourceId contents_resource_id = ca_layer_overlay.contents_resource_id; | 3776 ResourceId contents_resource_id = ca_layer_overlay.contents_resource_id; |
| 3777 unsigned texture_id = 0; | 3777 unsigned texture_id = 0; |
| 3778 if (contents_resource_id) { | 3778 if (contents_resource_id) { |
| 3779 pending_overlay_resources_.push_back( | 3779 pending_overlay_resources_.push_back( |
| 3780 base::WrapUnique(new ResourceProvider::ScopedReadLockGL( | 3780 base::MakeUnique<ResourceProvider::ScopedReadLockGL>( |
| 3781 resource_provider_, contents_resource_id))); | 3781 resource_provider_, contents_resource_id)); |
| 3782 texture_id = pending_overlay_resources_.back()->texture_id(); | 3782 texture_id = pending_overlay_resources_.back()->texture_id(); |
| 3783 } | 3783 } |
| 3784 GLfloat contents_rect[4] = { | 3784 GLfloat contents_rect[4] = { |
| 3785 ca_layer_overlay.contents_rect.x(), ca_layer_overlay.contents_rect.y(), | 3785 ca_layer_overlay.contents_rect.x(), ca_layer_overlay.contents_rect.y(), |
| 3786 ca_layer_overlay.contents_rect.width(), | 3786 ca_layer_overlay.contents_rect.width(), |
| 3787 ca_layer_overlay.contents_rect.height(), | 3787 ca_layer_overlay.contents_rect.height(), |
| 3788 }; | 3788 }; |
| 3789 GLfloat bounds_rect[4] = { | 3789 GLfloat bounds_rect[4] = { |
| 3790 ca_layer_overlay.bounds_rect.x(), ca_layer_overlay.bounds_rect.y(), | 3790 ca_layer_overlay.bounds_rect.x(), ca_layer_overlay.bounds_rect.y(), |
| 3791 ca_layer_overlay.bounds_rect.width(), | 3791 ca_layer_overlay.bounds_rect.width(), |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3826 return; | 3826 return; |
| 3827 | 3827 |
| 3828 OverlayCandidateList& overlays = frame->overlay_list; | 3828 OverlayCandidateList& overlays = frame->overlay_list; |
| 3829 for (const OverlayCandidate& overlay : overlays) { | 3829 for (const OverlayCandidate& overlay : overlays) { |
| 3830 unsigned texture_id = 0; | 3830 unsigned texture_id = 0; |
| 3831 if (overlay.use_output_surface_for_resource) { | 3831 if (overlay.use_output_surface_for_resource) { |
| 3832 texture_id = output_surface_->GetOverlayTextureId(); | 3832 texture_id = output_surface_->GetOverlayTextureId(); |
| 3833 DCHECK(texture_id || IsContextLost()); | 3833 DCHECK(texture_id || IsContextLost()); |
| 3834 } else { | 3834 } else { |
| 3835 pending_overlay_resources_.push_back( | 3835 pending_overlay_resources_.push_back( |
| 3836 base::WrapUnique(new ResourceProvider::ScopedReadLockGL( | 3836 base::MakeUnique<ResourceProvider::ScopedReadLockGL>( |
| 3837 resource_provider_, overlay.resource_id))); | 3837 resource_provider_, overlay.resource_id)); |
| 3838 texture_id = pending_overlay_resources_.back()->texture_id(); | 3838 texture_id = pending_overlay_resources_.back()->texture_id(); |
| 3839 } | 3839 } |
| 3840 | 3840 |
| 3841 context_support_->ScheduleOverlayPlane( | 3841 context_support_->ScheduleOverlayPlane( |
| 3842 overlay.plane_z_order, overlay.transform, texture_id, | 3842 overlay.plane_z_order, overlay.transform, texture_id, |
| 3843 ToNearestRect(overlay.display_rect), overlay.uv_rect); | 3843 ToNearestRect(overlay.display_rect), overlay.uv_rect); |
| 3844 } | 3844 } |
| 3845 } | 3845 } |
| 3846 | 3846 |
| 3847 // This function draws the RenderPassDrawQuad into a temporary | 3847 // This function draws the RenderPassDrawQuad into a temporary |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3998 } | 3998 } |
| 3999 | 3999 |
| 4000 Resource* resource = nullptr; | 4000 Resource* resource = nullptr; |
| 4001 gfx::RectF new_bounds; | 4001 gfx::RectF new_bounds; |
| 4002 CopyRenderPassDrawQuadToOverlayResource(ca_layer_overlay, &resource, | 4002 CopyRenderPassDrawQuadToOverlayResource(ca_layer_overlay, &resource, |
| 4003 external_frame, &new_bounds); | 4003 external_frame, &new_bounds); |
| 4004 if (!resource || !resource->id()) | 4004 if (!resource || !resource->id()) |
| 4005 return; | 4005 return; |
| 4006 | 4006 |
| 4007 pending_overlay_resources_.push_back( | 4007 pending_overlay_resources_.push_back( |
| 4008 base::WrapUnique(new ResourceProvider::ScopedReadLockGL( | 4008 base::MakeUnique<ResourceProvider::ScopedReadLockGL>(resource_provider_, |
| 4009 resource_provider_, resource->id()))); | 4009 resource->id())); |
| 4010 unsigned texture_id = pending_overlay_resources_.back()->texture_id(); | 4010 unsigned texture_id = pending_overlay_resources_.back()->texture_id(); |
| 4011 | 4011 |
| 4012 // Once a resource is released, it is marked as "busy". It will be | 4012 // Once a resource is released, it is marked as "busy". It will be |
| 4013 // available for reuse after the ScopedReadLockGL is destroyed. | 4013 // available for reuse after the ScopedReadLockGL is destroyed. |
| 4014 overlay_resource_pool_->ReleaseResource(resource); | 4014 overlay_resource_pool_->ReleaseResource(resource); |
| 4015 | 4015 |
| 4016 GLfloat contents_rect[4] = { | 4016 GLfloat contents_rect[4] = { |
| 4017 ca_layer_overlay->contents_rect.x(), ca_layer_overlay->contents_rect.y(), | 4017 ca_layer_overlay->contents_rect.x(), ca_layer_overlay->contents_rect.y(), |
| 4018 ca_layer_overlay->contents_rect.width(), | 4018 ca_layer_overlay->contents_rect.width(), |
| 4019 ca_layer_overlay->contents_rect.height(), | 4019 ca_layer_overlay->contents_rect.height(), |
| (...skipping 14 matching lines...) Expand all Loading... |
| 4034 | 4034 |
| 4035 gl_->ScheduleCALayerSharedStateCHROMIUM( | 4035 gl_->ScheduleCALayerSharedStateCHROMIUM( |
| 4036 ca_layer_overlay->shared_state->opacity, is_clipped, clip_rect, | 4036 ca_layer_overlay->shared_state->opacity, is_clipped, clip_rect, |
| 4037 sorting_context_id, gl_transform); | 4037 sorting_context_id, gl_transform); |
| 4038 gl_->ScheduleCALayerCHROMIUM( | 4038 gl_->ScheduleCALayerCHROMIUM( |
| 4039 texture_id, contents_rect, ca_layer_overlay->background_color, | 4039 texture_id, contents_rect, ca_layer_overlay->background_color, |
| 4040 ca_layer_overlay->edge_aa_mask, bounds_rect, filter); | 4040 ca_layer_overlay->edge_aa_mask, bounds_rect, filter); |
| 4041 } | 4041 } |
| 4042 | 4042 |
| 4043 } // namespace cc | 4043 } // namespace cc |
| OLD | NEW |