| 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 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 834 | 834 |
| 835 std::unique_ptr<ScopedResource> GLRenderer::GetBackdropTexture( | 835 std::unique_ptr<ScopedResource> GLRenderer::GetBackdropTexture( |
| 836 const gfx::Rect& bounding_rect) { | 836 const gfx::Rect& bounding_rect) { |
| 837 std::unique_ptr<ScopedResource> device_background_texture = | 837 std::unique_ptr<ScopedResource> device_background_texture = |
| 838 ScopedResource::Create(resource_provider_); | 838 ScopedResource::Create(resource_provider_); |
| 839 // CopyTexImage2D fails when called on a texture having immutable storage. | 839 // CopyTexImage2D fails when called on a texture having immutable storage. |
| 840 device_background_texture->Allocate( | 840 device_background_texture->Allocate( |
| 841 bounding_rect.size(), ResourceProvider::TEXTURE_HINT_DEFAULT, | 841 bounding_rect.size(), ResourceProvider::TEXTURE_HINT_DEFAULT, |
| 842 resource_provider_->best_texture_format()); | 842 resource_provider_->best_texture_format()); |
| 843 { | 843 { |
| 844 ResourceProvider::ScopedWriteLockGL lock(resource_provider_, | 844 ResourceProvider::ScopedWriteLockGL lock( |
| 845 device_background_texture->id()); | 845 resource_provider_, device_background_texture->id(), false); |
| 846 GetFramebufferTexture(lock.texture_id(), RGBA_8888, bounding_rect); | 846 GetFramebufferTexture(lock.ProduceTextureId(), RGBA_8888, bounding_rect); |
| 847 lock.ReleaseTextureId(); |
| 847 } | 848 } |
| 848 return device_background_texture; | 849 return device_background_texture; |
| 849 } | 850 } |
| 850 | 851 |
| 851 sk_sp<SkImage> GLRenderer::ApplyBackgroundFilters( | 852 sk_sp<SkImage> GLRenderer::ApplyBackgroundFilters( |
| 852 DrawingFrame* frame, | 853 DrawingFrame* frame, |
| 853 const RenderPassDrawQuad* quad, | 854 const RenderPassDrawQuad* quad, |
| 854 ScopedResource* background_texture, | 855 ScopedResource* background_texture, |
| 855 const gfx::RectF& rect) { | 856 const gfx::RectF& rect) { |
| 856 DCHECK(ShouldApplyBackgroundFilters(quad)); | 857 DCHECK(ShouldApplyBackgroundFilters(quad)); |
| (...skipping 2123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2980 DCHECK(texture->id()); | 2981 DCHECK(texture->id()); |
| 2981 | 2982 |
| 2982 // Explicitly release lock, otherwise we can crash when try to lock | 2983 // Explicitly release lock, otherwise we can crash when try to lock |
| 2983 // same texture again. | 2984 // same texture again. |
| 2984 current_framebuffer_lock_ = nullptr; | 2985 current_framebuffer_lock_ = nullptr; |
| 2985 | 2986 |
| 2986 SetStencilEnabled(false); | 2987 SetStencilEnabled(false); |
| 2987 gl_->BindFramebuffer(GL_FRAMEBUFFER, offscreen_framebuffer_id_); | 2988 gl_->BindFramebuffer(GL_FRAMEBUFFER, offscreen_framebuffer_id_); |
| 2988 current_framebuffer_lock_ = | 2989 current_framebuffer_lock_ = |
| 2989 base::WrapUnique(new ResourceProvider::ScopedWriteLockGL( | 2990 base::WrapUnique(new ResourceProvider::ScopedWriteLockGL( |
| 2990 resource_provider_, texture->id())); | 2991 resource_provider_, texture->id(), false)); |
| 2991 unsigned texture_id = current_framebuffer_lock_->texture_id(); | 2992 unsigned texture_id = current_framebuffer_lock_->ProduceTextureId(); |
| 2992 gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, | 2993 gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
| 2993 texture_id, 0); | 2994 texture_id, 0); |
| 2995 current_framebuffer_lock_->ReleaseTextureId(); |
| 2994 | 2996 |
| 2995 DCHECK(gl_->CheckFramebufferStatus(GL_FRAMEBUFFER) == | 2997 DCHECK(gl_->CheckFramebufferStatus(GL_FRAMEBUFFER) == |
| 2996 GL_FRAMEBUFFER_COMPLETE || | 2998 GL_FRAMEBUFFER_COMPLETE || |
| 2997 IsContextLost()); | 2999 IsContextLost()); |
| 2998 return true; | 3000 return true; |
| 2999 } | 3001 } |
| 3000 | 3002 |
| 3001 void GLRenderer::SetScissorTestRect(const gfx::Rect& scissor_rect) { | 3003 void GLRenderer::SetScissorTestRect(const gfx::Rect& scissor_rect) { |
| 3002 EnsureScissorTestEnabled(); | 3004 EnsureScissorTestEnabled(); |
| 3003 | 3005 |
| (...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3648 texture_id = pending_overlay_resources_.back()->texture_id(); | 3650 texture_id = pending_overlay_resources_.back()->texture_id(); |
| 3649 } | 3651 } |
| 3650 | 3652 |
| 3651 context_support_->ScheduleOverlayPlane( | 3653 context_support_->ScheduleOverlayPlane( |
| 3652 overlay.plane_z_order, overlay.transform, texture_id, | 3654 overlay.plane_z_order, overlay.transform, texture_id, |
| 3653 ToNearestRect(overlay.display_rect), overlay.uv_rect); | 3655 ToNearestRect(overlay.display_rect), overlay.uv_rect); |
| 3654 } | 3656 } |
| 3655 } | 3657 } |
| 3656 | 3658 |
| 3657 } // namespace cc | 3659 } // namespace cc |
| OLD | NEW |