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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 // Parameters needed to draw a RenderPassDrawQuad. | 153 // Parameters needed to draw a RenderPassDrawQuad. |
154 struct DrawRenderPassDrawQuadParams { | 154 struct DrawRenderPassDrawQuadParams { |
155 DrawRenderPassDrawQuadParams() {} | 155 DrawRenderPassDrawQuadParams() {} |
156 ~DrawRenderPassDrawQuadParams() {} | 156 ~DrawRenderPassDrawQuadParams() {} |
157 | 157 |
158 // Required Inputs. | 158 // Required Inputs. |
159 const RenderPassDrawQuad* quad = nullptr; | 159 const RenderPassDrawQuad* quad = nullptr; |
160 const Resource* contents_texture = nullptr; | 160 const Resource* contents_texture = nullptr; |
161 const gfx::QuadF* clip_region = nullptr; | 161 const gfx::QuadF* clip_region = nullptr; |
162 bool flip_texture = false; | 162 bool flip_texture = false; |
163 | |
164 gfx::Transform window_matrix; | 163 gfx::Transform window_matrix; |
165 gfx::Transform projection_matrix; | 164 gfx::Transform projection_matrix; |
| 165 gfx::Transform quad_to_target_transform; |
166 | 166 |
167 // |frame| is needed for background effects. | 167 // |frame| is only used for background effects. |
168 DirectRenderer::DrawingFrame* frame = nullptr; | 168 DirectRenderer::DrawingFrame* frame = nullptr; |
169 | 169 |
170 // Whether the texture to be sampled from needs to be flipped. | 170 // Whether the texture to be sampled from needs to be flipped. |
171 bool source_needs_flip = false; | 171 bool source_needs_flip = false; |
172 | 172 |
173 float edge[24]; | 173 float edge[24]; |
174 SkScalar color_matrix[20]; | 174 SkScalar color_matrix[20]; |
175 | 175 |
176 // Blending refers to modifications to the backdrop. | 176 // Blending refers to modifications to the backdrop. |
177 bool use_shaders_for_blending = false; | 177 bool use_shaders_for_blending = false; |
(...skipping 30 matching lines...) Expand all Loading... |
208 GLuint background_image_id = 0; | 208 GLuint background_image_id = 0; |
209 | 209 |
210 // Whether the original background texture is needed for the mask. | 210 // Whether the original background texture is needed for the mask. |
211 bool mask_for_background = false; | 211 bool mask_for_background = false; |
212 | 212 |
213 // Whether a color matrix needs to be applied by the shaders when drawing | 213 // Whether a color matrix needs to be applied by the shaders when drawing |
214 // the RPDQ. | 214 // the RPDQ. |
215 bool use_color_matrix = false; | 215 bool use_color_matrix = false; |
216 | 216 |
217 gfx::QuadF surface_quad; | 217 gfx::QuadF surface_quad; |
| 218 |
218 gfx::Transform contents_device_transform; | 219 gfx::Transform contents_device_transform; |
219 }; | 220 }; |
220 | 221 |
221 static GLint GetActiveTextureUnit(GLES2Interface* gl) { | 222 static GLint GetActiveTextureUnit(GLES2Interface* gl) { |
222 GLint active_unit = 0; | 223 GLint active_unit = 0; |
223 gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit); | 224 gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit); |
224 return active_unit; | 225 return active_unit; |
225 } | 226 } |
226 | 227 |
227 class GLRenderer::ScopedUseGrContext { | 228 class GLRenderer::ScopedUseGrContext { |
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1061 // See above comments about texture flipping. When the input is a | 1062 // See above comments about texture flipping. When the input is a |
1062 // render pass, it needs to an extra flip to be oriented correctly. | 1063 // render pass, it needs to an extra flip to be oriented correctly. |
1063 params.flip_texture = true; | 1064 params.flip_texture = true; |
1064 params.contents_texture = contents_texture; | 1065 params.contents_texture = contents_texture; |
1065 DrawRenderPassQuadInternal(¶ms); | 1066 DrawRenderPassQuadInternal(¶ms); |
1066 } | 1067 } |
1067 } | 1068 } |
1068 | 1069 |
1069 void GLRenderer::DrawRenderPassQuadInternal( | 1070 void GLRenderer::DrawRenderPassQuadInternal( |
1070 DrawRenderPassDrawQuadParams* params) { | 1071 DrawRenderPassDrawQuadParams* params) { |
| 1072 params->quad_to_target_transform = |
| 1073 params->quad->shared_quad_state->quad_to_target_transform; |
1071 if (!InitializeRPDQParameters(params)) | 1074 if (!InitializeRPDQParameters(params)) |
1072 return; | 1075 return; |
1073 UpdateRPDQShadersForBlending(params); | 1076 UpdateRPDQShadersForBlending(params); |
1074 if (!UpdateRPDQWithSkiaFilters(params)) | 1077 if (!UpdateRPDQWithSkiaFilters(params)) |
1075 return; | 1078 return; |
1076 UseRenderPass(params->frame, params->frame->current_render_pass); | 1079 UseRenderPass(params->frame, params->frame->current_render_pass); |
1077 SetViewport(); | 1080 SetViewport(); |
1078 UpdateRPDQTexturesForSampling(params); | 1081 UpdateRPDQTexturesForSampling(params); |
1079 UpdateRPDQBlendMode(params); | 1082 UpdateRPDQBlendMode(params); |
1080 ChooseRPDQProgram(params); | 1083 ChooseRPDQProgram(params); |
1081 UpdateRPDQUniforms(params); | 1084 UpdateRPDQUniforms(params); |
1082 DrawRPDQ(*params); | 1085 DrawRPDQ(*params); |
1083 } | 1086 } |
1084 | 1087 |
1085 bool GLRenderer::InitializeRPDQParameters( | 1088 bool GLRenderer::InitializeRPDQParameters( |
1086 DrawRenderPassDrawQuadParams* params) { | 1089 DrawRenderPassDrawQuadParams* params) { |
1087 const RenderPassDrawQuad* quad = params->quad; | 1090 const RenderPassDrawQuad* quad = params->quad; |
1088 SkMatrix scale_matrix; | 1091 SkMatrix scale_matrix; |
1089 scale_matrix.setScale(quad->filters_scale.x(), quad->filters_scale.y()); | 1092 scale_matrix.setScale(quad->filters_scale.x(), quad->filters_scale.y()); |
1090 gfx::Rect dst_rect = quad->filters.MapRect(quad->rect, scale_matrix); | 1093 gfx::Rect dst_rect = quad->filters.MapRect(quad->rect, scale_matrix); |
1091 params->dst_rect.SetRect(static_cast<float>(dst_rect.x()), | 1094 params->dst_rect.SetRect(static_cast<float>(dst_rect.x()), |
1092 static_cast<float>(dst_rect.y()), | 1095 static_cast<float>(dst_rect.y()), |
1093 static_cast<float>(dst_rect.width()), | 1096 static_cast<float>(dst_rect.width()), |
1094 static_cast<float>(dst_rect.height())); | 1097 static_cast<float>(dst_rect.height())); |
1095 gfx::Transform quad_rect_matrix; | 1098 gfx::Transform quad_rect_matrix; |
1096 QuadRectTransform(&quad_rect_matrix, | 1099 QuadRectTransform(&quad_rect_matrix, params->quad_to_target_transform, |
1097 quad->shared_quad_state->quad_to_target_transform, | |
1098 params->dst_rect); | 1100 params->dst_rect); |
1099 params->contents_device_transform = | 1101 params->contents_device_transform = |
1100 params->window_matrix * params->projection_matrix * quad_rect_matrix; | 1102 params->window_matrix * params->projection_matrix * quad_rect_matrix; |
1101 params->contents_device_transform.FlattenTo2d(); | 1103 params->contents_device_transform.FlattenTo2d(); |
1102 | 1104 |
1103 // Can only draw surface if device matrix is invertible. | 1105 // Can only draw surface if device matrix is invertible. |
1104 if (!params->contents_device_transform.IsInvertible()) | 1106 if (!params->contents_device_transform.IsInvertible()) |
1105 return false; | 1107 return false; |
1106 | 1108 |
1107 params->surface_quad = SharedGeometryQuad(); | 1109 params->surface_quad = SharedGeometryQuad(); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1210 // locally in the compositor and process the rest of the DAG (if any) | 1212 // locally in the compositor and process the rest of the DAG (if any) |
1211 // in Skia. | 1213 // in Skia. |
1212 params->use_color_matrix = true; | 1214 params->use_color_matrix = true; |
1213 filter = sk_ref_sp(filter->getInput(0)); | 1215 filter = sk_ref_sp(filter->getInput(0)); |
1214 } | 1216 } |
1215 if (filter) { | 1217 if (filter) { |
1216 gfx::Rect clip_rect = quad->shared_quad_state->clip_rect; | 1218 gfx::Rect clip_rect = quad->shared_quad_state->clip_rect; |
1217 if (clip_rect.IsEmpty()) { | 1219 if (clip_rect.IsEmpty()) { |
1218 clip_rect = current_draw_rect_; | 1220 clip_rect = current_draw_rect_; |
1219 } | 1221 } |
1220 gfx::Transform transform = | 1222 gfx::Transform transform = params->quad_to_target_transform; |
1221 quad->shared_quad_state->quad_to_target_transform; | |
1222 gfx::QuadF clip_quad = gfx::QuadF(gfx::RectF(clip_rect)); | 1223 gfx::QuadF clip_quad = gfx::QuadF(gfx::RectF(clip_rect)); |
1223 gfx::QuadF local_clip = MapQuadToLocalSpace(transform, clip_quad); | 1224 gfx::QuadF local_clip = MapQuadToLocalSpace(transform, clip_quad); |
1224 params->dst_rect.Intersect(local_clip.BoundingBox()); | 1225 params->dst_rect.Intersect(local_clip.BoundingBox()); |
1225 // If we've been fully clipped out (by crop rect or clipping), there's | 1226 // If we've been fully clipped out (by crop rect or clipping), there's |
1226 // nothing to draw. | 1227 // nothing to draw. |
1227 if (params->dst_rect.IsEmpty()) { | 1228 if (params->dst_rect.IsEmpty()) { |
1228 return false; | 1229 return false; |
1229 } | 1230 } |
1230 SkIPoint offset; | 1231 SkIPoint offset; |
1231 SkIRect subset; | 1232 SkIRect subset; |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1492 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), | 1493 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), |
1493 params->shader_background_sampler_lock->target()); | 1494 params->shader_background_sampler_lock->target()); |
1494 } | 1495 } |
1495 } | 1496 } |
1496 | 1497 |
1497 SetShaderOpacity(params->quad->shared_quad_state->opacity, locations.alpha); | 1498 SetShaderOpacity(params->quad->shared_quad_state->opacity, locations.alpha); |
1498 SetShaderQuadF(params->surface_quad, locations.quad); | 1499 SetShaderQuadF(params->surface_quad, locations.quad); |
1499 } | 1500 } |
1500 | 1501 |
1501 void GLRenderer::DrawRPDQ(const DrawRenderPassDrawQuadParams& params) { | 1502 void GLRenderer::DrawRPDQ(const DrawRenderPassDrawQuadParams& params) { |
1502 DrawQuadGeometry(params.projection_matrix, | 1503 DrawQuadGeometry(params.projection_matrix, params.quad_to_target_transform, |
1503 params.quad->shared_quad_state->quad_to_target_transform, | |
1504 params.dst_rect, params.locations.matrix); | 1504 params.dst_rect, params.locations.matrix); |
1505 | 1505 |
1506 // Flush the compositor context before the filter bitmap goes out of | 1506 // Flush the compositor context before the filter bitmap goes out of |
1507 // scope, so the draw gets processed before the filter texture gets deleted. | 1507 // scope, so the draw gets processed before the filter texture gets deleted. |
1508 if (params.filter_image) | 1508 if (params.filter_image) |
1509 gl_->Flush(); | 1509 gl_->Flush(); |
1510 | 1510 |
1511 if (!params.use_shaders_for_blending) | 1511 if (!params.use_shaders_for_blending) |
1512 RestoreBlendFuncToDefault(params.quad->shared_quad_state->blend_mode); | 1512 RestoreBlendFuncToDefault(params.quad->shared_quad_state->blend_mode); |
1513 } | 1513 } |
(...skipping 1207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2721 | 2721 |
2722 ScheduleCALayers(frame); | 2722 ScheduleCALayers(frame); |
2723 ScheduleOverlays(frame); | 2723 ScheduleOverlays(frame); |
2724 } | 2724 } |
2725 | 2725 |
2726 void GLRenderer::FinishDrawingQuadList() { | 2726 void GLRenderer::FinishDrawingQuadList() { |
2727 FlushTextureQuadCache(SHARED_BINDING); | 2727 FlushTextureQuadCache(SHARED_BINDING); |
2728 } | 2728 } |
2729 | 2729 |
2730 bool GLRenderer::FlippedFramebuffer(const DrawingFrame* frame) const { | 2730 bool GLRenderer::FlippedFramebuffer(const DrawingFrame* frame) const { |
| 2731 if (frame == force_drawing_frame_framebuffer_flipped_) |
| 2732 return true; |
2731 if (frame->current_render_pass != frame->root_render_pass) | 2733 if (frame->current_render_pass != frame->root_render_pass) |
2732 return true; | 2734 return true; |
2733 return FlippedRootFramebuffer(); | 2735 return FlippedRootFramebuffer(); |
2734 } | 2736 } |
2735 | 2737 |
2736 bool GLRenderer::FlippedRootFramebuffer() const { | 2738 bool GLRenderer::FlippedRootFramebuffer() const { |
2737 // GL is normally flipped, so a flipped output results in an unflipping. | 2739 // GL is normally flipped, so a flipped output results in an unflipping. |
2738 return !output_surface_->capabilities().flipped_output_surface; | 2740 return !output_surface_->capabilities().flipped_output_surface; |
2739 } | 2741 } |
2740 | 2742 |
(...skipping 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3770 } | 3772 } |
3771 | 3773 |
3772 bool GLRenderer::IsContextLost() { | 3774 bool GLRenderer::IsContextLost() { |
3773 return gl_->GetGraphicsResetStatusKHR() != GL_NO_ERROR; | 3775 return gl_->GetGraphicsResetStatusKHR() != GL_NO_ERROR; |
3774 } | 3776 } |
3775 | 3777 |
3776 void GLRenderer::ScheduleCALayers(DrawingFrame* frame) { | 3778 void GLRenderer::ScheduleCALayers(DrawingFrame* frame) { |
3777 scoped_refptr<CALayerOverlaySharedState> shared_state; | 3779 scoped_refptr<CALayerOverlaySharedState> shared_state; |
3778 size_t copied_render_pass_count = 0; | 3780 size_t copied_render_pass_count = 0; |
3779 for (const CALayerOverlay& ca_layer_overlay : frame->ca_layer_overlay_list) { | 3781 for (const CALayerOverlay& ca_layer_overlay : frame->ca_layer_overlay_list) { |
3780 if (!overlay_resource_pool_) { | 3782 if (ca_layer_overlay.rpdq) { |
3781 overlay_resource_pool_ = ResourcePool::CreateForGpuMemoryBufferResources( | 3783 ScheduleRenderPassDrawQuad(&ca_layer_overlay, frame); |
3782 resource_provider_, base::ThreadTaskRunnerHandle::Get().get(), | 3784 shared_state = nullptr; |
3783 gfx::BufferUsage::SCANOUT); | 3785 ++copied_render_pass_count; |
| 3786 continue; |
3784 } | 3787 } |
3785 | 3788 |
3786 ResourceId contents_resource_id = ca_layer_overlay.contents_resource_id; | 3789 ResourceId contents_resource_id = ca_layer_overlay.contents_resource_id; |
3787 unsigned texture_id = 0; | 3790 unsigned texture_id = 0; |
3788 if (contents_resource_id) { | 3791 if (contents_resource_id) { |
3789 pending_overlay_resources_.push_back( | 3792 pending_overlay_resources_.push_back( |
3790 base::WrapUnique(new ResourceProvider::ScopedReadLockGL( | 3793 base::WrapUnique(new ResourceProvider::ScopedReadLockGL( |
3791 resource_provider_, contents_resource_id))); | 3794 resource_provider_, contents_resource_id))); |
3792 texture_id = pending_overlay_resources_.back()->texture_id(); | 3795 texture_id = pending_overlay_resources_.back()->texture_id(); |
3793 } | 3796 } |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3847 resource_provider_, overlay.resource_id))); | 3850 resource_provider_, overlay.resource_id))); |
3848 texture_id = pending_overlay_resources_.back()->texture_id(); | 3851 texture_id = pending_overlay_resources_.back()->texture_id(); |
3849 } | 3852 } |
3850 | 3853 |
3851 context_support_->ScheduleOverlayPlane( | 3854 context_support_->ScheduleOverlayPlane( |
3852 overlay.plane_z_order, overlay.transform, texture_id, | 3855 overlay.plane_z_order, overlay.transform, texture_id, |
3853 ToNearestRect(overlay.display_rect), overlay.uv_rect); | 3856 ToNearestRect(overlay.display_rect), overlay.uv_rect); |
3854 } | 3857 } |
3855 } | 3858 } |
3856 | 3859 |
| 3860 // This function draws the RenderPassDrawQuad into a temporary |
| 3861 // texture/framebuffer, and then copies the result into an IOSurface. The |
| 3862 // inefficient (but simple) way to do this would be to: |
| 3863 // 1. Allocate a framebuffer the size of the screen. |
| 3864 // 2. Draw using all the normal RPDQ draw logic. |
| 3865 // Instead, this method does the following: |
| 3866 // 1. Configure parameters as if drawing to a framebuffer the size of the |
| 3867 // screen. This reuses most of the RPDQ draw logic. |
| 3868 // 2. Update parameters to draw into a framebuffer only as large as needed. |
| 3869 // 3. Fix shader uniforms that were broken by (2). |
| 3870 // |
| 3871 // Then: |
| 3872 // 4. Allocate a temporary TEXTURE_2D as the drawing destination. |
| 3873 // 5. Draw the RPDQ. |
| 3874 // 6. Copy from the temporary texture into an IOSurface. |
| 3875 void GLRenderer::CopyRenderPassDrawQuadToOverlayResource( |
| 3876 const CALayerOverlay* ca_layer_overlay, |
| 3877 Resource** resource, |
| 3878 DrawingFrame* external_frame, |
| 3879 gfx::RectF* new_bounds) { |
| 3880 ScopedResource* contents_texture = |
| 3881 render_pass_textures_[ca_layer_overlay->rpdq->render_pass_id].get(); |
| 3882 DCHECK(contents_texture); |
| 3883 |
| 3884 // Configure parameters as if drawing to a framebuffer the size of the |
| 3885 // screen. |
| 3886 DrawRenderPassDrawQuadParams params; |
| 3887 params.quad = ca_layer_overlay->rpdq; |
| 3888 params.flip_texture = false; |
| 3889 params.contents_texture = contents_texture; |
| 3890 params.quad_to_target_transform = |
| 3891 params.quad->shared_quad_state->quad_to_target_transform; |
| 3892 |
| 3893 // Calculate projection and window matrices using InitializeViewport(). This |
| 3894 // requires creating a dummy DrawingFrame. |
| 3895 { |
| 3896 DrawingFrame frame; |
| 3897 gfx::Rect frame_rect = external_frame->device_viewport_rect; |
| 3898 force_drawing_frame_framebuffer_flipped_ = &frame; |
| 3899 InitializeViewport(&frame, frame_rect, frame_rect, frame_rect.size()); |
| 3900 force_drawing_frame_framebuffer_flipped_ = nullptr; |
| 3901 params.projection_matrix = frame.projection_matrix; |
| 3902 params.window_matrix = frame.window_matrix; |
| 3903 } |
| 3904 |
| 3905 // Perform basic initialization with the screen-sized viewport. |
| 3906 if (!InitializeRPDQParameters(¶ms)) |
| 3907 return; |
| 3908 if (!UpdateRPDQWithSkiaFilters(¶ms)) |
| 3909 return; |
| 3910 |
| 3911 // Compute the rect that encloses the image of the quad in the viewport. |
| 3912 gfx::Rect quad_image_rect; |
| 3913 gfx::RectF quad_image_rectf; |
| 3914 { |
| 3915 gfx::RectF dst_rect_image = params.dst_rect; |
| 3916 params.quad_to_target_transform.TransformRect(&dst_rect_image); |
| 3917 quad_image_rect = gfx::ToEnclosingRect(dst_rect_image); |
| 3918 quad_image_rectf = gfx::RectF(quad_image_rect); |
| 3919 } |
| 3920 *new_bounds = gfx::RectF(quad_image_rect); |
| 3921 |
| 3922 // Create in *resource an overlay-capable resource the size of that rect, and |
| 3923 // bind it to a temporary framebuffer. |
| 3924 *resource = overlay_resource_pool_->AcquireResource( |
| 3925 quad_image_rect.size(), ResourceFormat::RGBA_8888); |
| 3926 ResourceProvider::ScopedWriteLockGL destination(resource_provider_, |
| 3927 (*resource)->id(), false); |
| 3928 GLuint temp_fbo = 0; |
| 3929 gl_->GenFramebuffers(1, &temp_fbo); |
| 3930 gl_->BindFramebuffer(GL_FRAMEBUFFER, temp_fbo); |
| 3931 gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, |
| 3932 destination.target(), destination.texture_id(), 0); |
| 3933 DCHECK(gl_->CheckFramebufferStatus(GL_FRAMEBUFFER) == |
| 3934 GL_FRAMEBUFFER_COMPLETE); |
| 3935 gl_->ClearColor(0, 0, 0, 0); |
| 3936 gl_->Clear(GL_COLOR_BUFFER_BIT); |
| 3937 |
| 3938 // Note that it is necessary to set up the samplers here, after *resource has |
| 3939 // been created, because resource creation will dirty texture binding state. |
| 3940 UpdateRPDQTexturesForSampling(¶ms); |
| 3941 UpdateRPDQBlendMode(¶ms); |
| 3942 ChooseRPDQProgram(¶ms); |
| 3943 UpdateRPDQUniforms(¶ms); |
| 3944 |
| 3945 // Set the viewport to be that image rect, moved to be at the origin. |
| 3946 gl_->Viewport(0, 0, quad_image_rect.width(), quad_image_rect.height()); |
| 3947 |
| 3948 // Update the RPDQ's transforms and viewport so that the image of the quad |
| 3949 // will be the new viewport. |
| 3950 params.projection_matrix.matrix().preScale( |
| 3951 current_window_space_viewport_.width() / quad_image_rectf.width(), |
| 3952 current_window_space_viewport_.height() / quad_image_rectf.height(), 1); |
| 3953 params.quad_to_target_transform.matrix().postTranslate( |
| 3954 -quad_image_rect.x(), -quad_image_rect.y(), 0); |
| 3955 |
| 3956 // Draw the quad into *resource. |
| 3957 gl_->BindFramebuffer(GL_FRAMEBUFFER, temp_fbo); |
| 3958 DrawRPDQ(params); |
| 3959 gl_->DeleteFramebuffers(1, &temp_fbo); |
| 3960 } |
| 3961 |
| 3962 void GLRenderer::ScheduleRenderPassDrawQuad( |
| 3963 const CALayerOverlay* ca_layer_overlay, |
| 3964 DrawingFrame* external_frame) { |
| 3965 DCHECK(ca_layer_overlay->rpdq); |
| 3966 |
| 3967 if (!overlay_resource_pool_) { |
| 3968 overlay_resource_pool_ = ResourcePool::CreateForGpuMemoryBufferResources( |
| 3969 resource_provider_, base::ThreadTaskRunnerHandle::Get().get(), |
| 3970 gfx::BufferUsage::SCANOUT); |
| 3971 } |
| 3972 |
| 3973 Resource* resource = nullptr; |
| 3974 gfx::RectF new_bounds; |
| 3975 CopyRenderPassDrawQuadToOverlayResource(ca_layer_overlay, &resource, |
| 3976 external_frame, &new_bounds); |
| 3977 if (!resource || !resource->id()) |
| 3978 return; |
| 3979 |
| 3980 pending_overlay_resources_.push_back( |
| 3981 base::WrapUnique(new ResourceProvider::ScopedReadLockGL( |
| 3982 resource_provider_, resource->id()))); |
| 3983 unsigned texture_id = pending_overlay_resources_.back()->texture_id(); |
| 3984 |
| 3985 // Once a resource is released, it is marked as "busy". It will be |
| 3986 // available for reuse after the ScopedReadLockGL is destroyed. |
| 3987 overlay_resource_pool_->ReleaseResource(resource); |
| 3988 |
| 3989 GLfloat contents_rect[4] = { |
| 3990 ca_layer_overlay->contents_rect.x(), ca_layer_overlay->contents_rect.y(), |
| 3991 ca_layer_overlay->contents_rect.width(), |
| 3992 ca_layer_overlay->contents_rect.height(), |
| 3993 }; |
| 3994 GLfloat bounds_rect[4] = { |
| 3995 new_bounds.x(), new_bounds.y(), new_bounds.width(), new_bounds.height(), |
| 3996 }; |
| 3997 GLboolean is_clipped = ca_layer_overlay->shared_state->is_clipped; |
| 3998 GLfloat clip_rect[4] = {ca_layer_overlay->shared_state->clip_rect.x(), |
| 3999 ca_layer_overlay->shared_state->clip_rect.y(), |
| 4000 ca_layer_overlay->shared_state->clip_rect.width(), |
| 4001 ca_layer_overlay->shared_state->clip_rect.height()}; |
| 4002 GLint sorting_context_id = ca_layer_overlay->shared_state->sorting_context_id; |
| 4003 DCHECK_EQ(0, sorting_context_id); |
| 4004 SkMatrix44 transform; |
| 4005 GLfloat gl_transform[16]; |
| 4006 transform.asColMajorf(gl_transform); |
| 4007 unsigned filter = ca_layer_overlay->filter; |
| 4008 |
| 4009 gl_->ScheduleCALayerSharedStateCHROMIUM( |
| 4010 ca_layer_overlay->shared_state->opacity, is_clipped, clip_rect, |
| 4011 sorting_context_id, gl_transform); |
| 4012 gl_->ScheduleCALayerCHROMIUM( |
| 4013 texture_id, contents_rect, ca_layer_overlay->background_color, |
| 4014 ca_layer_overlay->edge_aa_mask, bounds_rect, filter); |
| 4015 } |
| 4016 |
3857 } // namespace cc | 4017 } // namespace cc |
OLD | NEW |