| 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 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 } | 589 } |
| 590 | 590 |
| 591 static sk_sp<SkImage> WrapTexture( | 591 static sk_sp<SkImage> WrapTexture( |
| 592 const ResourceProvider::ScopedReadLockGL& lock, | 592 const ResourceProvider::ScopedReadLockGL& lock, |
| 593 GrContext* context) { | 593 GrContext* context) { |
| 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 = kBottomLeft_GrSurfaceOrigin; | 604 backend_texture_description.fOrigin = kBottomLeft_GrSurfaceOrigin; |
| 605 | 605 |
| 606 return SkImage::MakeFromTexture(context, backend_texture_description); | 606 return SkImage::MakeFromTexture(context, backend_texture_description); |
| 607 } | 607 } |
| 608 | 608 |
| 609 static sk_sp<SkImage> ApplyImageFilter( | 609 static sk_sp<SkImage> ApplyImageFilter( |
| 610 std::unique_ptr<GLRenderer::ScopedUseGrContext> use_gr_context, | 610 std::unique_ptr<GLRenderer::ScopedUseGrContext> use_gr_context, |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 820 | 820 |
| 821 std::unique_ptr<ScopedResource> GLRenderer::GetBackdropTexture( | 821 std::unique_ptr<ScopedResource> GLRenderer::GetBackdropTexture( |
| 822 const gfx::Rect& bounding_rect) { | 822 const gfx::Rect& bounding_rect) { |
| 823 std::unique_ptr<ScopedResource> device_background_texture = | 823 std::unique_ptr<ScopedResource> device_background_texture = |
| 824 ScopedResource::Create(resource_provider_); | 824 ScopedResource::Create(resource_provider_); |
| 825 // CopyTexImage2D fails when called on a texture having immutable storage. | 825 // CopyTexImage2D fails when called on a texture having immutable storage. |
| 826 device_background_texture->Allocate( | 826 device_background_texture->Allocate( |
| 827 bounding_rect.size(), ResourceProvider::TEXTURE_HINT_DEFAULT, | 827 bounding_rect.size(), ResourceProvider::TEXTURE_HINT_DEFAULT, |
| 828 resource_provider_->best_texture_format()); | 828 resource_provider_->best_texture_format()); |
| 829 { | 829 { |
| 830 ResourceProvider::ScopedWriteLockGL lock(resource_provider_, | 830 ResourceProvider::ScopedWriteLockGL lock( |
| 831 device_background_texture->id()); | 831 resource_provider_, device_background_texture->id(), false); |
| 832 GetFramebufferTexture(lock.texture_id(), RGBA_8888, bounding_rect); | 832 GetFramebufferTexture(lock.texture_id(), RGBA_8888, bounding_rect); |
| 833 } | 833 } |
| 834 return device_background_texture; | 834 return device_background_texture; |
| 835 } | 835 } |
| 836 | 836 |
| 837 sk_sp<SkImage> GLRenderer::ApplyBackgroundFilters( | 837 sk_sp<SkImage> GLRenderer::ApplyBackgroundFilters( |
| 838 DrawingFrame* frame, | 838 DrawingFrame* frame, |
| 839 const RenderPassDrawQuad* quad, | 839 const RenderPassDrawQuad* quad, |
| 840 ScopedResource* background_texture, | 840 ScopedResource* background_texture, |
| 841 const gfx::RectF& rect) { | 841 const gfx::RectF& rect) { |
| (...skipping 1611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2453 draw_cache_.matrix_location = binding.matrix_location; | 2453 draw_cache_.matrix_location = binding.matrix_location; |
| 2454 draw_cache_.sampler_location = binding.sampler_location; | 2454 draw_cache_.sampler_location = binding.sampler_location; |
| 2455 } | 2455 } |
| 2456 | 2456 |
| 2457 // Generate the uv-transform | 2457 // Generate the uv-transform |
| 2458 Float4 uv_transform = {{0.0f, 0.0f, 1.0f, 1.0f}}; | 2458 Float4 uv_transform = {{0.0f, 0.0f, 1.0f, 1.0f}}; |
| 2459 if (!clip_region) | 2459 if (!clip_region) |
| 2460 uv_transform = UVTransform(quad); | 2460 uv_transform = UVTransform(quad); |
| 2461 if (sampler == SAMPLER_TYPE_2D_RECT) { | 2461 if (sampler == SAMPLER_TYPE_2D_RECT) { |
| 2462 // Un-normalize the texture coordiantes for rectangle targets. | 2462 // Un-normalize the texture coordiantes for rectangle targets. |
| 2463 gfx::Size texture_size = lock.texture_size(); | 2463 gfx::Size texture_size = lock.size(); |
| 2464 uv_transform.data[0] *= texture_size.width(); | 2464 uv_transform.data[0] *= texture_size.width(); |
| 2465 uv_transform.data[2] *= texture_size.width(); | 2465 uv_transform.data[2] *= texture_size.width(); |
| 2466 uv_transform.data[1] *= texture_size.height(); | 2466 uv_transform.data[1] *= texture_size.height(); |
| 2467 uv_transform.data[3] *= texture_size.height(); | 2467 uv_transform.data[3] *= texture_size.height(); |
| 2468 } | 2468 } |
| 2469 draw_cache_.uv_xform_data.push_back(uv_transform); | 2469 draw_cache_.uv_xform_data.push_back(uv_transform); |
| 2470 | 2470 |
| 2471 // Generate the vertex opacity | 2471 // Generate the vertex opacity |
| 2472 const float opacity = quad->shared_quad_state->opacity; | 2472 const float opacity = quad->shared_quad_state->opacity; |
| 2473 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[0] * opacity); | 2473 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[0] * opacity); |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2963 DCHECK(texture->id()); | 2963 DCHECK(texture->id()); |
| 2964 | 2964 |
| 2965 // Explicitly release lock, otherwise we can crash when try to lock | 2965 // Explicitly release lock, otherwise we can crash when try to lock |
| 2966 // same texture again. | 2966 // same texture again. |
| 2967 current_framebuffer_lock_ = nullptr; | 2967 current_framebuffer_lock_ = nullptr; |
| 2968 | 2968 |
| 2969 SetStencilEnabled(false); | 2969 SetStencilEnabled(false); |
| 2970 gl_->BindFramebuffer(GL_FRAMEBUFFER, offscreen_framebuffer_id_); | 2970 gl_->BindFramebuffer(GL_FRAMEBUFFER, offscreen_framebuffer_id_); |
| 2971 current_framebuffer_lock_ = | 2971 current_framebuffer_lock_ = |
| 2972 base::WrapUnique(new ResourceProvider::ScopedWriteLockGL( | 2972 base::WrapUnique(new ResourceProvider::ScopedWriteLockGL( |
| 2973 resource_provider_, texture->id())); | 2973 resource_provider_, texture->id(), false)); |
| 2974 unsigned texture_id = current_framebuffer_lock_->texture_id(); | 2974 unsigned texture_id = current_framebuffer_lock_->texture_id(); |
| 2975 gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, | 2975 gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
| 2976 texture_id, 0); | 2976 texture_id, 0); |
| 2977 | 2977 |
| 2978 DCHECK(gl_->CheckFramebufferStatus(GL_FRAMEBUFFER) == | 2978 DCHECK(gl_->CheckFramebufferStatus(GL_FRAMEBUFFER) == |
| 2979 GL_FRAMEBUFFER_COMPLETE || | 2979 GL_FRAMEBUFFER_COMPLETE || |
| 2980 IsContextLost()); | 2980 IsContextLost()); |
| 2981 return true; | 2981 return true; |
| 2982 } | 2982 } |
| 2983 | 2983 |
| (...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3617 texture_id = pending_overlay_resources_.back()->texture_id(); | 3617 texture_id = pending_overlay_resources_.back()->texture_id(); |
| 3618 } | 3618 } |
| 3619 | 3619 |
| 3620 context_support_->ScheduleOverlayPlane( | 3620 context_support_->ScheduleOverlayPlane( |
| 3621 overlay.plane_z_order, overlay.transform, texture_id, | 3621 overlay.plane_z_order, overlay.transform, texture_id, |
| 3622 ToNearestRect(overlay.display_rect), overlay.uv_rect); | 3622 ToNearestRect(overlay.display_rect), overlay.uv_rect); |
| 3623 } | 3623 } |
| 3624 } | 3624 } |
| 3625 | 3625 |
| 3626 } // namespace cc | 3626 } // namespace cc |
| OLD | NEW |