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 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.size().width(); | 599 backend_texture_description.fWidth = lock.texture_size().width(); |
600 backend_texture_description.fHeight = lock.size().height(); | 600 backend_texture_description.fHeight = lock.texture_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 Loading... |
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( | 834 ResourceProvider::ScopedWriteLockGL lock(resource_provider_, |
835 resource_provider_, device_background_texture->id(), false); | 835 device_background_texture->id()); |
836 GetFramebufferTexture(lock.texture_id(), RGBA_8888, bounding_rect); | 836 GetFramebufferTexture(lock.texture_id(), RGBA_8888, 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 1690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2536 draw_cache_.matrix_location = binding.matrix_location; | 2536 draw_cache_.matrix_location = binding.matrix_location; |
2537 draw_cache_.sampler_location = binding.sampler_location; | 2537 draw_cache_.sampler_location = binding.sampler_location; |
2538 } | 2538 } |
2539 | 2539 |
2540 // Generate the uv-transform | 2540 // Generate the uv-transform |
2541 Float4 uv_transform = {{0.0f, 0.0f, 1.0f, 1.0f}}; | 2541 Float4 uv_transform = {{0.0f, 0.0f, 1.0f, 1.0f}}; |
2542 if (!clip_region) | 2542 if (!clip_region) |
2543 uv_transform = UVTransform(quad); | 2543 uv_transform = UVTransform(quad); |
2544 if (sampler == SAMPLER_TYPE_2D_RECT) { | 2544 if (sampler == SAMPLER_TYPE_2D_RECT) { |
2545 // Un-normalize the texture coordiantes for rectangle targets. | 2545 // Un-normalize the texture coordiantes for rectangle targets. |
2546 gfx::Size texture_size = lock.size(); | 2546 gfx::Size texture_size = lock.texture_size(); |
2547 uv_transform.data[0] *= texture_size.width(); | 2547 uv_transform.data[0] *= texture_size.width(); |
2548 uv_transform.data[2] *= texture_size.width(); | 2548 uv_transform.data[2] *= texture_size.width(); |
2549 uv_transform.data[1] *= texture_size.height(); | 2549 uv_transform.data[1] *= texture_size.height(); |
2550 uv_transform.data[3] *= texture_size.height(); | 2550 uv_transform.data[3] *= texture_size.height(); |
2551 } | 2551 } |
2552 draw_cache_.uv_xform_data.push_back(uv_transform); | 2552 draw_cache_.uv_xform_data.push_back(uv_transform); |
2553 | 2553 |
2554 // Generate the vertex opacity | 2554 // Generate the vertex opacity |
2555 const float opacity = quad->shared_quad_state->opacity; | 2555 const float opacity = quad->shared_quad_state->opacity; |
2556 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[0] * opacity); | 2556 draw_cache_.vertex_opacity_data.push_back(quad->vertex_opacity[0] * opacity); |
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3079 DCHECK(texture->id()); | 3079 DCHECK(texture->id()); |
3080 | 3080 |
3081 // Explicitly release lock, otherwise we can crash when try to lock | 3081 // Explicitly release lock, otherwise we can crash when try to lock |
3082 // same texture again. | 3082 // same texture again. |
3083 current_framebuffer_lock_ = nullptr; | 3083 current_framebuffer_lock_ = nullptr; |
3084 | 3084 |
3085 SetStencilEnabled(false); | 3085 SetStencilEnabled(false); |
3086 gl_->BindFramebuffer(GL_FRAMEBUFFER, offscreen_framebuffer_id_); | 3086 gl_->BindFramebuffer(GL_FRAMEBUFFER, offscreen_framebuffer_id_); |
3087 current_framebuffer_lock_ = | 3087 current_framebuffer_lock_ = |
3088 base::WrapUnique(new ResourceProvider::ScopedWriteLockGL( | 3088 base::WrapUnique(new ResourceProvider::ScopedWriteLockGL( |
3089 resource_provider_, texture->id(), false)); | 3089 resource_provider_, texture->id())); |
3090 unsigned texture_id = current_framebuffer_lock_->texture_id(); | 3090 unsigned texture_id = current_framebuffer_lock_->texture_id(); |
3091 gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, | 3091 gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
3092 texture_id, 0); | 3092 texture_id, 0); |
3093 | 3093 |
3094 DCHECK(gl_->CheckFramebufferStatus(GL_FRAMEBUFFER) == | 3094 DCHECK(gl_->CheckFramebufferStatus(GL_FRAMEBUFFER) == |
3095 GL_FRAMEBUFFER_COMPLETE || | 3095 GL_FRAMEBUFFER_COMPLETE || |
3096 IsContextLost()); | 3096 IsContextLost()); |
3097 return true; | 3097 return true; |
3098 } | 3098 } |
3099 | 3099 |
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3733 texture_id = pending_overlay_resources_.back()->texture_id(); | 3733 texture_id = pending_overlay_resources_.back()->texture_id(); |
3734 } | 3734 } |
3735 | 3735 |
3736 context_support_->ScheduleOverlayPlane( | 3736 context_support_->ScheduleOverlayPlane( |
3737 overlay.plane_z_order, overlay.transform, texture_id, | 3737 overlay.plane_z_order, overlay.transform, texture_id, |
3738 ToNearestRect(overlay.display_rect), overlay.uv_rect); | 3738 ToNearestRect(overlay.display_rect), overlay.uv_rect); |
3739 } | 3739 } |
3740 } | 3740 } |
3741 | 3741 |
3742 } // namespace cc | 3742 } // namespace cc |
OLD | NEW |