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

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

Issue 2046033002: Revert of cc: Add mailbox support to ResourceProvider write locks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@worker_context_stream
Patch Set: Created 4 years, 6 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
« no previous file with comments | « cc/cc.gyp ('k') | cc/raster/gpu_raster_buffer_provider.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 } 588 }
589 589
590 static sk_sp<SkImage> WrapTexture( 590 static sk_sp<SkImage> WrapTexture(
591 const ResourceProvider::ScopedReadLockGL& lock, 591 const ResourceProvider::ScopedReadLockGL& lock,
592 GrContext* context) { 592 GrContext* context) {
593 // Wrap a given texture in a Ganesh platform texture. 593 // Wrap a given texture in a Ganesh platform texture.
594 GrBackendTextureDesc backend_texture_description; 594 GrBackendTextureDesc backend_texture_description;
595 GrGLTextureInfo texture_info; 595 GrGLTextureInfo texture_info;
596 texture_info.fTarget = lock.target(); 596 texture_info.fTarget = lock.target();
597 texture_info.fID = lock.texture_id(); 597 texture_info.fID = lock.texture_id();
598 backend_texture_description.fWidth = lock.size().width(); 598 backend_texture_description.fWidth = lock.texture_size().width();
599 backend_texture_description.fHeight = lock.size().height(); 599 backend_texture_description.fHeight = lock.texture_size().height();
600 backend_texture_description.fConfig = kSkia8888_GrPixelConfig; 600 backend_texture_description.fConfig = kSkia8888_GrPixelConfig;
601 backend_texture_description.fTextureHandle = 601 backend_texture_description.fTextureHandle =
602 skia::GrGLTextureInfoToGrBackendObject(texture_info); 602 skia::GrGLTextureInfoToGrBackendObject(texture_info);
603 backend_texture_description.fOrigin = kBottomLeft_GrSurfaceOrigin; 603 backend_texture_description.fOrigin = kBottomLeft_GrSurfaceOrigin;
604 604
605 return SkImage::MakeFromTexture(context, backend_texture_description); 605 return SkImage::MakeFromTexture(context, backend_texture_description);
606 } 606 }
607 607
608 static sk_sp<SkImage> ApplyImageFilter( 608 static sk_sp<SkImage> ApplyImageFilter(
609 std::unique_ptr<GLRenderer::ScopedUseGrContext> use_gr_context, 609 std::unique_ptr<GLRenderer::ScopedUseGrContext> use_gr_context,
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 819
820 std::unique_ptr<ScopedResource> GLRenderer::GetBackdropTexture( 820 std::unique_ptr<ScopedResource> GLRenderer::GetBackdropTexture(
821 const gfx::Rect& bounding_rect) { 821 const gfx::Rect& bounding_rect) {
822 std::unique_ptr<ScopedResource> device_background_texture = 822 std::unique_ptr<ScopedResource> device_background_texture =
823 ScopedResource::Create(resource_provider_); 823 ScopedResource::Create(resource_provider_);
824 // CopyTexImage2D fails when called on a texture having immutable storage. 824 // CopyTexImage2D fails when called on a texture having immutable storage.
825 device_background_texture->Allocate( 825 device_background_texture->Allocate(
826 bounding_rect.size(), ResourceProvider::TEXTURE_HINT_DEFAULT, 826 bounding_rect.size(), ResourceProvider::TEXTURE_HINT_DEFAULT,
827 resource_provider_->best_texture_format()); 827 resource_provider_->best_texture_format());
828 { 828 {
829 ResourceProvider::ScopedWriteLockGL lock( 829 ResourceProvider::ScopedWriteLockGL lock(resource_provider_,
830 resource_provider_, device_background_texture->id(), false); 830 device_background_texture->id());
831 GetFramebufferTexture(lock.texture_id(), RGBA_8888, bounding_rect); 831 GetFramebufferTexture(lock.texture_id(), RGBA_8888, bounding_rect);
832 } 832 }
833 return device_background_texture; 833 return device_background_texture;
834 } 834 }
835 835
836 sk_sp<SkImage> GLRenderer::ApplyBackgroundFilters( 836 sk_sp<SkImage> GLRenderer::ApplyBackgroundFilters(
837 DrawingFrame* frame, 837 DrawingFrame* frame,
838 const RenderPassDrawQuad* quad, 838 const RenderPassDrawQuad* quad,
839 ScopedResource* background_texture, 839 ScopedResource* background_texture,
840 const gfx::RectF& rect) { 840 const gfx::RectF& rect) {
(...skipping 1611 matching lines...) Expand 10 before | Expand all | Expand 10 after
2452 draw_cache_.matrix_location = binding.matrix_location; 2452 draw_cache_.matrix_location = binding.matrix_location;
2453 draw_cache_.sampler_location = binding.sampler_location; 2453 draw_cache_.sampler_location = binding.sampler_location;
2454 } 2454 }
2455 2455
2456 // Generate the uv-transform 2456 // Generate the uv-transform
2457 Float4 uv_transform = {{0.0f, 0.0f, 1.0f, 1.0f}}; 2457 Float4 uv_transform = {{0.0f, 0.0f, 1.0f, 1.0f}};
2458 if (!clip_region) 2458 if (!clip_region)
2459 uv_transform = UVTransform(quad); 2459 uv_transform = UVTransform(quad);
2460 if (sampler == SAMPLER_TYPE_2D_RECT) { 2460 if (sampler == SAMPLER_TYPE_2D_RECT) {
2461 // Un-normalize the texture coordiantes for rectangle targets. 2461 // Un-normalize the texture coordiantes for rectangle targets.
2462 gfx::Size texture_size = lock.size(); 2462 gfx::Size texture_size = lock.texture_size();
2463 uv_transform.data[0] *= texture_size.width(); 2463 uv_transform.data[0] *= texture_size.width();
2464 uv_transform.data[2] *= texture_size.width(); 2464 uv_transform.data[2] *= texture_size.width();
2465 uv_transform.data[1] *= texture_size.height(); 2465 uv_transform.data[1] *= texture_size.height();
2466 uv_transform.data[3] *= texture_size.height(); 2466 uv_transform.data[3] *= texture_size.height();
2467 } 2467 }
2468 draw_cache_.uv_xform_data.push_back(uv_transform); 2468 draw_cache_.uv_xform_data.push_back(uv_transform);
2469 2469
2470 // Generate the vertex opacity 2470 // Generate the vertex opacity
2471 const float opacity = quad->shared_quad_state->opacity; 2471 const float opacity = quad->shared_quad_state->opacity;
2472 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[0] * opacity); 2472 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[0] * opacity);
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
2716 // |swapped_and_acked_overlay_resources_|, and then erases resources from 2716 // |swapped_and_acked_overlay_resources_|, and then erases resources from
2717 // |swapped_and_acked_overlay_resources_| that are no longer in use by the 2717 // |swapped_and_acked_overlay_resources_| that are no longer in use by the
2718 // Window Server. On other platforms, since resources are never in use by the 2718 // Window Server. On other platforms, since resources are never in use by the
2719 // Window Server, this is equivalent to just erasing all resources from the 2719 // Window Server, this is equivalent to just erasing all resources from the
2720 // first element of |swapping_overlay_resources_|. 2720 // first element of |swapping_overlay_resources_|.
2721 if (settings_->release_overlay_resources_on_swap_complete) { 2721 if (settings_->release_overlay_resources_on_swap_complete) {
2722 // Move resources known to be acked into 2722 // Move resources known to be acked into
2723 // |swapped_and_acked_overlay_resources_|. 2723 // |swapped_and_acked_overlay_resources_|.
2724 if (!swapping_overlay_resources_.empty()) { 2724 if (!swapping_overlay_resources_.empty()) {
2725 for (OverlayResourceLock& lock : swapping_overlay_resources_.front()) { 2725 for (OverlayResourceLock& lock : swapping_overlay_resources_.front()) {
2726 swapped_and_acked_overlay_resources_[lock->resource_id()] = 2726 swapped_and_acked_overlay_resources_[lock->GetResourceId()] =
2727 std::move(lock); 2727 std::move(lock);
2728 } 2728 }
2729 swapping_overlay_resources_.pop_front(); 2729 swapping_overlay_resources_.pop_front();
2730 } 2730 }
2731 2731
2732 // Release resources that are no longer in use by the Window Server. 2732 // Release resources that are no longer in use by the Window Server.
2733 auto it = swapped_and_acked_overlay_resources_.begin(); 2733 auto it = swapped_and_acked_overlay_resources_.begin();
2734 while (it != swapped_and_acked_overlay_resources_.end()) { 2734 while (it != swapped_and_acked_overlay_resources_.end()) {
2735 if (it->second->gpu_memory_buffer() && 2735 if (it->second->GetGpuMemoryBuffer() &&
2736 it->second->gpu_memory_buffer()->IsInUseByMacOSWindowServer()) { 2736 it->second->GetGpuMemoryBuffer()->IsInUseByMacOSWindowServer()) {
2737 ++it; 2737 ++it;
2738 continue; 2738 continue;
2739 } 2739 }
2740 2740
2741 it = swapped_and_acked_overlay_resources_.erase(it); 2741 it = swapped_and_acked_overlay_resources_.erase(it);
2742 } 2742 }
2743 } 2743 }
2744 } 2744 }
2745 2745
2746 void GLRenderer::EnforceMemoryPolicy() { 2746 void GLRenderer::EnforceMemoryPolicy() {
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
2990 DCHECK(texture->id()); 2990 DCHECK(texture->id());
2991 2991
2992 // Explicitly release lock, otherwise we can crash when try to lock 2992 // Explicitly release lock, otherwise we can crash when try to lock
2993 // same texture again. 2993 // same texture again.
2994 current_framebuffer_lock_ = nullptr; 2994 current_framebuffer_lock_ = nullptr;
2995 2995
2996 SetStencilEnabled(false); 2996 SetStencilEnabled(false);
2997 gl_->BindFramebuffer(GL_FRAMEBUFFER, offscreen_framebuffer_id_); 2997 gl_->BindFramebuffer(GL_FRAMEBUFFER, offscreen_framebuffer_id_);
2998 current_framebuffer_lock_ = 2998 current_framebuffer_lock_ =
2999 base::WrapUnique(new ResourceProvider::ScopedWriteLockGL( 2999 base::WrapUnique(new ResourceProvider::ScopedWriteLockGL(
3000 resource_provider_, texture->id(), false)); 3000 resource_provider_, texture->id()));
3001 unsigned texture_id = current_framebuffer_lock_->texture_id(); 3001 unsigned texture_id = current_framebuffer_lock_->texture_id();
3002 gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 3002 gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
3003 texture_id, 0); 3003 texture_id, 0);
3004 3004
3005 DCHECK(gl_->CheckFramebufferStatus(GL_FRAMEBUFFER) == 3005 DCHECK(gl_->CheckFramebufferStatus(GL_FRAMEBUFFER) ==
3006 GL_FRAMEBUFFER_COMPLETE || 3006 GL_FRAMEBUFFER_COMPLETE ||
3007 IsContextLost()); 3007 IsContextLost());
3008 return true; 3008 return true;
3009 } 3009 }
3010 3010
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 (const 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.contents_resource_id) {
3598 pending_overlay_resources_.push_back( 3598 pending_overlay_resources_.push_back(
3599 base::WrapUnique(new ResourceProvider::ScopedReadLockGpuMemoryBuffer( 3599 base::WrapUnique(new ResourceProvider::ScopedReadLockGpuMemoryBuffer(
3600 resource_provider_, ca_layer_overlay.contents_resource_id))); 3600 resource_provider_, ca_layer_overlay.contents_resource_id)));
3601 texture_id = pending_overlay_resources_.back()->texture_id(); 3601 texture_id = pending_overlay_resources_.back()->GetTextureId();
3602 } 3602 }
3603 GLfloat contents_rect[4] = { 3603 GLfloat contents_rect[4] = {
3604 ca_layer_overlay.contents_rect.x(), ca_layer_overlay.contents_rect.y(), 3604 ca_layer_overlay.contents_rect.x(), ca_layer_overlay.contents_rect.y(),
3605 ca_layer_overlay.contents_rect.width(), 3605 ca_layer_overlay.contents_rect.width(),
3606 ca_layer_overlay.contents_rect.height(), 3606 ca_layer_overlay.contents_rect.height(),
3607 }; 3607 };
3608 GLfloat bounds_rect[4] = { 3608 GLfloat bounds_rect[4] = {
3609 ca_layer_overlay.bounds_rect.x(), ca_layer_overlay.bounds_rect.y(), 3609 ca_layer_overlay.bounds_rect.x(), ca_layer_overlay.bounds_rect.y(),
3610 ca_layer_overlay.bounds_rect.width(), 3610 ca_layer_overlay.bounds_rect.width(),
3611 ca_layer_overlay.bounds_rect.height(), 3611 ca_layer_overlay.bounds_rect.height(),
(...skipping 22 matching lines...) Expand all
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()->texture_id(); 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
« no previous file with comments | « cc/cc.gyp ('k') | cc/raster/gpu_raster_buffer_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698