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

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

Issue 2081883002: Reland of cc: Add mailbox support to ResourceProvider write locks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@worker_context_sync_tokens_revert
Patch Set: rebase Created 4 years, 5 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 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 bool flip_texture) { 593 bool flip_texture) {
594 // Wrap a given texture in a Ganesh platform texture. 594 // Wrap a given texture in a Ganesh platform texture.
595 GrBackendTextureDesc backend_texture_description; 595 GrBackendTextureDesc backend_texture_description;
596 GrGLTextureInfo texture_info; 596 GrGLTextureInfo texture_info;
597 texture_info.fTarget = lock.target(); 597 texture_info.fTarget = lock.target();
598 texture_info.fID = lock.texture_id(); 598 texture_info.fID = lock.texture_id();
599 backend_texture_description.fWidth = lock.texture_size().width(); 599 backend_texture_description.fWidth = lock.size().width();
600 backend_texture_description.fHeight = lock.texture_size().height(); 600 backend_texture_description.fHeight = lock.size().height();
601 backend_texture_description.fConfig = kSkia8888_GrPixelConfig; 601 backend_texture_description.fConfig = kSkia8888_GrPixelConfig;
602 backend_texture_description.fTextureHandle = 602 backend_texture_description.fTextureHandle =
603 skia::GrGLTextureInfoToGrBackendObject(texture_info); 603 skia::GrGLTextureInfoToGrBackendObject(texture_info);
604 backend_texture_description.fOrigin = 604 backend_texture_description.fOrigin =
605 flip_texture ? kBottomLeft_GrSurfaceOrigin : kTopLeft_GrSurfaceOrigin; 605 flip_texture ? kBottomLeft_GrSurfaceOrigin : kTopLeft_GrSurfaceOrigin;
606 606
607 return SkImage::MakeFromTexture(context, backend_texture_description); 607 return SkImage::MakeFromTexture(context, backend_texture_description);
608 } 608 }
609 609
610 static sk_sp<SkImage> ApplyImageFilter( 610 static sk_sp<SkImage> ApplyImageFilter(
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 824
825 std::unique_ptr<ScopedResource> GLRenderer::GetBackdropTexture( 825 std::unique_ptr<ScopedResource> GLRenderer::GetBackdropTexture(
826 const gfx::Rect& bounding_rect) { 826 const gfx::Rect& bounding_rect) {
827 std::unique_ptr<ScopedResource> device_background_texture = 827 std::unique_ptr<ScopedResource> device_background_texture =
828 ScopedResource::Create(resource_provider_); 828 ScopedResource::Create(resource_provider_);
829 // CopyTexImage2D fails when called on a texture having immutable storage. 829 // CopyTexImage2D fails when called on a texture having immutable storage.
830 device_background_texture->Allocate( 830 device_background_texture->Allocate(
831 bounding_rect.size(), ResourceProvider::TEXTURE_HINT_DEFAULT, 831 bounding_rect.size(), ResourceProvider::TEXTURE_HINT_DEFAULT,
832 resource_provider_->best_texture_format()); 832 resource_provider_->best_texture_format());
833 { 833 {
834 ResourceProvider::ScopedWriteLockGL lock(resource_provider_, 834 ResourceProvider::ScopedWriteLockGL lock(
835 device_background_texture->id()); 835 resource_provider_, device_background_texture->id(), false);
836 GetFramebufferTexture(lock.texture_id(), bounding_rect); 836 GetFramebufferTexture(lock.texture_id(), bounding_rect);
837 } 837 }
838 return device_background_texture; 838 return device_background_texture;
839 } 839 }
840 840
841 sk_sp<SkImage> GLRenderer::ApplyBackgroundFilters( 841 sk_sp<SkImage> GLRenderer::ApplyBackgroundFilters(
842 DrawingFrame* frame, 842 DrawingFrame* frame,
843 const RenderPassDrawQuad* quad, 843 const RenderPassDrawQuad* quad,
844 ScopedResource* background_texture, 844 ScopedResource* background_texture,
845 const gfx::RectF& rect) { 845 const gfx::RectF& rect) {
(...skipping 1652 matching lines...) Expand 10 before | Expand all | Expand 10 after
2498 draw_cache_.matrix_location = binding.matrix_location; 2498 draw_cache_.matrix_location = binding.matrix_location;
2499 draw_cache_.sampler_location = binding.sampler_location; 2499 draw_cache_.sampler_location = binding.sampler_location;
2500 } 2500 }
2501 2501
2502 // Generate the uv-transform 2502 // Generate the uv-transform
2503 Float4 uv_transform = {{0.0f, 0.0f, 1.0f, 1.0f}}; 2503 Float4 uv_transform = {{0.0f, 0.0f, 1.0f, 1.0f}};
2504 if (!clip_region) 2504 if (!clip_region)
2505 uv_transform = UVTransform(quad); 2505 uv_transform = UVTransform(quad);
2506 if (sampler == SAMPLER_TYPE_2D_RECT) { 2506 if (sampler == SAMPLER_TYPE_2D_RECT) {
2507 // Un-normalize the texture coordiantes for rectangle targets. 2507 // Un-normalize the texture coordiantes for rectangle targets.
2508 gfx::Size texture_size = lock.texture_size(); 2508 gfx::Size texture_size = lock.size();
2509 uv_transform.data[0] *= texture_size.width(); 2509 uv_transform.data[0] *= texture_size.width();
2510 uv_transform.data[2] *= texture_size.width(); 2510 uv_transform.data[2] *= texture_size.width();
2511 uv_transform.data[1] *= texture_size.height(); 2511 uv_transform.data[1] *= texture_size.height();
2512 uv_transform.data[3] *= texture_size.height(); 2512 uv_transform.data[3] *= texture_size.height();
2513 } 2513 }
2514 draw_cache_.uv_xform_data.push_back(uv_transform); 2514 draw_cache_.uv_xform_data.push_back(uv_transform);
2515 2515
2516 // Generate the vertex opacity 2516 // Generate the vertex opacity
2517 const float opacity = quad->shared_quad_state->opacity; 2517 const float opacity = quad->shared_quad_state->opacity;
2518 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[0] * opacity); 2518 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[0] * opacity);
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
3050 DCHECK(texture->id()); 3050 DCHECK(texture->id());
3051 3051
3052 // Explicitly release lock, otherwise we can crash when try to lock 3052 // Explicitly release lock, otherwise we can crash when try to lock
3053 // same texture again. 3053 // same texture again.
3054 current_framebuffer_lock_ = nullptr; 3054 current_framebuffer_lock_ = nullptr;
3055 3055
3056 SetStencilEnabled(false); 3056 SetStencilEnabled(false);
3057 gl_->BindFramebuffer(GL_FRAMEBUFFER, offscreen_framebuffer_id_); 3057 gl_->BindFramebuffer(GL_FRAMEBUFFER, offscreen_framebuffer_id_);
3058 current_framebuffer_lock_ = 3058 current_framebuffer_lock_ =
3059 base::WrapUnique(new ResourceProvider::ScopedWriteLockGL( 3059 base::WrapUnique(new ResourceProvider::ScopedWriteLockGL(
3060 resource_provider_, texture->id())); 3060 resource_provider_, texture->id(), false));
3061 current_framebuffer_format_ = texture->format(); 3061 current_framebuffer_format_ = texture->format();
3062 unsigned texture_id = current_framebuffer_lock_->texture_id(); 3062 unsigned texture_id = current_framebuffer_lock_->texture_id();
3063 gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 3063 gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
3064 texture_id, 0); 3064 texture_id, 0);
3065 3065
3066 DCHECK(gl_->CheckFramebufferStatus(GL_FRAMEBUFFER) == 3066 DCHECK(gl_->CheckFramebufferStatus(GL_FRAMEBUFFER) ==
3067 GL_FRAMEBUFFER_COMPLETE || 3067 GL_FRAMEBUFFER_COMPLETE ||
3068 IsContextLost()); 3068 IsContextLost());
3069 return true; 3069 return true;
3070 } 3070 }
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
3679 texture_id = pending_overlay_resources_.back()->texture_id(); 3679 texture_id = pending_overlay_resources_.back()->texture_id();
3680 } 3680 }
3681 3681
3682 context_support_->ScheduleOverlayPlane( 3682 context_support_->ScheduleOverlayPlane(
3683 overlay.plane_z_order, overlay.transform, texture_id, 3683 overlay.plane_z_order, overlay.transform, texture_id,
3684 ToNearestRect(overlay.display_rect), overlay.uv_rect); 3684 ToNearestRect(overlay.display_rect), overlay.uv_rect);
3685 } 3685 }
3686 } 3686 }
3687 3687
3688 } // namespace cc 3688 } // 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