Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Side by Side Diff: cc/output/gl_renderer.cc

Issue 2017473002: cc: Lock resources directly in CALayerOverlay (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 3574 matching lines...) Expand 10 before | Expand all | Expand 10 after
3585 // PrepareSurfaceForPass also clears the surface, which is not desired when 3585 // PrepareSurfaceForPass also clears the surface, which is not desired when
3586 // restoring. 3586 // restoring.
3587 SetViewport(); 3587 SetViewport();
3588 } 3588 }
3589 3589
3590 bool GLRenderer::IsContextLost() { 3590 bool GLRenderer::IsContextLost() {
3591 return gl_->GetGraphicsResetStatusKHR() != GL_NO_ERROR; 3591 return gl_->GetGraphicsResetStatusKHR() != GL_NO_ERROR;
3592 } 3592 }
3593 3593
3594 void GLRenderer::ScheduleCALayers(DrawingFrame* frame) { 3594 void GLRenderer::ScheduleCALayers(DrawingFrame* frame) {
3595 for (const CALayerOverlay& ca_layer_overlay : frame->ca_layer_overlay_list) { 3595 for (CALayerOverlay& ca_layer_overlay : frame->ca_layer_overlay_list) {
3596 unsigned texture_id = 0; 3596 unsigned texture_id = 0;
3597 if (ca_layer_overlay.contents_resource_id) { 3597 if (ca_layer_overlay.resource_lock) {
3598 texture_id = ca_layer_overlay.resource_lock->GetTextureId();
3598 pending_overlay_resources_.push_back( 3599 pending_overlay_resources_.push_back(
3599 base::WrapUnique(new ResourceProvider::ScopedReadLockGpuMemoryBuffer( 3600 std::move(ca_layer_overlay.resource_lock));
3600 resource_provider_, ca_layer_overlay.contents_resource_id)));
3601 texture_id = pending_overlay_resources_.back()->GetTextureId();
3602 } 3601 }
3603 GLfloat contents_rect[4] = { 3602 GLfloat contents_rect[4] = {
3604 ca_layer_overlay.contents_rect.x(), ca_layer_overlay.contents_rect.y(), 3603 ca_layer_overlay.contents_rect.x(), ca_layer_overlay.contents_rect.y(),
3605 ca_layer_overlay.contents_rect.width(), 3604 ca_layer_overlay.contents_rect.width(),
3606 ca_layer_overlay.contents_rect.height(), 3605 ca_layer_overlay.contents_rect.height(),
3607 }; 3606 };
3608 GLfloat bounds_rect[4] = { 3607 GLfloat bounds_rect[4] = {
3609 ca_layer_overlay.bounds_rect.x(), ca_layer_overlay.bounds_rect.y(), 3608 ca_layer_overlay.bounds_rect.x(), ca_layer_overlay.bounds_rect.y(),
3610 ca_layer_overlay.bounds_rect.width(), 3609 ca_layer_overlay.bounds_rect.width(),
3611 ca_layer_overlay.bounds_rect.height(), 3610 ca_layer_overlay.bounds_rect.height(),
3612 }; 3611 };
3613 GLboolean is_clipped = ca_layer_overlay.is_clipped; 3612 GLboolean is_clipped = ca_layer_overlay.is_clipped;
3614 GLfloat clip_rect[4] = {ca_layer_overlay.clip_rect.x(), 3613 GLfloat clip_rect[4] = {ca_layer_overlay.clip_rect.x(),
3615 ca_layer_overlay.clip_rect.y(), 3614 ca_layer_overlay.clip_rect.y(),
3616 ca_layer_overlay.clip_rect.width(), 3615 ca_layer_overlay.clip_rect.width(),
3617 ca_layer_overlay.clip_rect.height()}; 3616 ca_layer_overlay.clip_rect.height()};
3618 GLint sorting_context_id = ca_layer_overlay.sorting_context_id; 3617 GLint sorting_context_id = ca_layer_overlay.sorting_context_id;
3619 GLfloat transform[16]; 3618 GLfloat transform[16];
3620 ca_layer_overlay.transform.asColMajorf(transform); 3619 ca_layer_overlay.transform.asColMajorf(transform);
3621 unsigned filter = GL_LINEAR; 3620 unsigned filter = GL_LINEAR;
3622 gl_->ScheduleCALayerCHROMIUM( 3621 gl_->ScheduleCALayerCHROMIUM(
3623 texture_id, contents_rect, ca_layer_overlay.opacity, 3622 texture_id, contents_rect, ca_layer_overlay.opacity,
3624 ca_layer_overlay.background_color, ca_layer_overlay.edge_aa_mask, 3623 ca_layer_overlay.background_color, ca_layer_overlay.edge_aa_mask,
3625 bounds_rect, is_clipped, clip_rect, sorting_context_id, transform, 3624 bounds_rect, is_clipped, clip_rect, sorting_context_id, transform,
3626 filter); 3625 filter);
3627 } 3626 }
3627 frame->ca_layer_overlay_list.clear();
3628 } 3628 }
3629 3629
3630 void GLRenderer::ScheduleOverlays(DrawingFrame* frame) { 3630 void GLRenderer::ScheduleOverlays(DrawingFrame* frame) {
3631 if (!frame->overlay_list.size()) 3631 if (!frame->overlay_list.size())
3632 return; 3632 return;
3633 3633
3634 OverlayCandidateList& overlays = frame->overlay_list; 3634 OverlayCandidateList& overlays = frame->overlay_list;
3635 for (const OverlayCandidate& overlay : overlays) { 3635 for (const OverlayCandidate& overlay : overlays) {
3636 unsigned texture_id = 0; 3636 unsigned texture_id = 0;
3637 if (overlay.use_output_surface_for_resource) { 3637 if (overlay.use_output_surface_for_resource) {
3638 texture_id = output_surface_->GetOverlayTextureId(); 3638 texture_id = output_surface_->GetOverlayTextureId();
3639 DCHECK(texture_id || IsContextLost()); 3639 DCHECK(texture_id || IsContextLost());
3640 } else { 3640 } else {
3641 pending_overlay_resources_.push_back( 3641 pending_overlay_resources_.push_back(
3642 base::WrapUnique(new ResourceProvider::ScopedReadLockGpuMemoryBuffer( 3642 base::WrapUnique(new ResourceProvider::ScopedReadLockGpuMemoryBuffer(
3643 resource_provider_, overlay.resource_id))); 3643 resource_provider_, overlay.resource_id)));
3644 texture_id = pending_overlay_resources_.back()->GetTextureId(); 3644 texture_id = pending_overlay_resources_.back()->GetTextureId();
3645 } 3645 }
3646 3646
3647 context_support_->ScheduleOverlayPlane( 3647 context_support_->ScheduleOverlayPlane(
3648 overlay.plane_z_order, overlay.transform, texture_id, 3648 overlay.plane_z_order, overlay.transform, texture_id,
3649 ToNearestRect(overlay.display_rect), overlay.uv_rect); 3649 ToNearestRect(overlay.display_rect), overlay.uv_rect);
3650 } 3650 }
3651 } 3651 }
3652 3652
3653 } // namespace cc 3653 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698