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 2928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2939 DCHECK_LE(window_rect.right(), current_surface_size_.width()); | 2939 DCHECK_LE(window_rect.right(), current_surface_size_.width()); |
2940 DCHECK_LE(window_rect.bottom(), current_surface_size_.height()); | 2940 DCHECK_LE(window_rect.bottom(), current_surface_size_.height()); |
2941 | 2941 |
2942 gl_->BindTexture(GL_TEXTURE_2D, texture_id); | 2942 gl_->BindTexture(GL_TEXTURE_2D, texture_id); |
2943 gl_->CopyTexImage2D(GL_TEXTURE_2D, 0, GLDataFormat(texture_format), | 2943 gl_->CopyTexImage2D(GL_TEXTURE_2D, 0, GLDataFormat(texture_format), |
2944 window_rect.x(), window_rect.y(), window_rect.width(), | 2944 window_rect.x(), window_rect.y(), window_rect.width(), |
2945 window_rect.height(), 0); | 2945 window_rect.height(), 0); |
2946 gl_->BindTexture(GL_TEXTURE_2D, 0); | 2946 gl_->BindTexture(GL_TEXTURE_2D, 0); |
2947 } | 2947 } |
2948 | 2948 |
2949 bool GLRenderer::UseScopedTexture(DrawingFrame* frame, | |
2950 const ScopedResource* texture, | |
2951 const gfx::Rect& viewport_rect) { | |
2952 DCHECK(texture->id()); | |
2953 frame->current_render_pass = NULL; | |
2954 frame->current_texture = texture; | |
2955 | |
2956 return BindFramebufferToTexture(frame, texture, viewport_rect); | |
2957 } | |
2958 | |
2959 void GLRenderer::BindFramebufferToOutputSurface(DrawingFrame* frame) { | 2949 void GLRenderer::BindFramebufferToOutputSurface(DrawingFrame* frame) { |
2960 current_framebuffer_lock_ = nullptr; | 2950 current_framebuffer_lock_ = nullptr; |
2961 output_surface_->BindFramebuffer(); | 2951 output_surface_->BindFramebuffer(); |
2962 | 2952 |
2963 if (output_surface_->HasExternalStencilTest()) { | 2953 if (output_surface_->HasExternalStencilTest()) { |
2964 output_surface_->ApplyExternalStencil(); | 2954 output_surface_->ApplyExternalStencil(); |
2965 SetStencilEnabled(true); | 2955 SetStencilEnabled(true); |
2966 } else { | 2956 } else { |
2967 SetStencilEnabled(false); | 2957 SetStencilEnabled(false); |
2968 } | 2958 } |
2969 } | 2959 } |
2970 | 2960 |
2971 bool GLRenderer::BindFramebufferToTexture(DrawingFrame* frame, | 2961 bool GLRenderer::BindFramebufferToTexture(DrawingFrame* frame, |
2972 const ScopedResource* texture, | 2962 const ScopedResource* texture) { |
2973 const gfx::Rect& target_rect) { | |
2974 DCHECK(texture->id()); | 2963 DCHECK(texture->id()); |
2975 | 2964 |
2976 // Explicitly release lock, otherwise we can crash when try to lock | 2965 // Explicitly release lock, otherwise we can crash when try to lock |
2977 // same texture again. | 2966 // same texture again. |
2978 current_framebuffer_lock_ = nullptr; | 2967 current_framebuffer_lock_ = nullptr; |
2979 | 2968 |
2980 SetStencilEnabled(false); | 2969 SetStencilEnabled(false); |
2981 gl_->BindFramebuffer(GL_FRAMEBUFFER, offscreen_framebuffer_id_); | 2970 gl_->BindFramebuffer(GL_FRAMEBUFFER, offscreen_framebuffer_id_); |
2982 current_framebuffer_lock_ = | 2971 current_framebuffer_lock_ = |
2983 make_scoped_ptr(new ResourceProvider::ScopedWriteLockGL( | 2972 make_scoped_ptr(new ResourceProvider::ScopedWriteLockGL( |
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3623 texture_id = pending_overlay_resources_.back()->texture_id(); | 3612 texture_id = pending_overlay_resources_.back()->texture_id(); |
3624 } | 3613 } |
3625 | 3614 |
3626 context_support_->ScheduleOverlayPlane( | 3615 context_support_->ScheduleOverlayPlane( |
3627 overlay.plane_z_order, overlay.transform, texture_id, | 3616 overlay.plane_z_order, overlay.transform, texture_id, |
3628 ToNearestRect(overlay.display_rect), overlay.uv_rect); | 3617 ToNearestRect(overlay.display_rect), overlay.uv_rect); |
3629 } | 3618 } |
3630 } | 3619 } |
3631 | 3620 |
3632 } // namespace cc | 3621 } // namespace cc |
OLD | NEW |