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 3924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3935 // Perform basic initialization with the screen-sized viewport. | 3935 // Perform basic initialization with the screen-sized viewport. |
3936 if (!InitializeRPDQParameters(¶ms)) | 3936 if (!InitializeRPDQParameters(¶ms)) |
3937 return; | 3937 return; |
3938 | 3938 |
3939 if (!UpdateRPDQWithSkiaFilters(¶ms)) | 3939 if (!UpdateRPDQWithSkiaFilters(¶ms)) |
3940 return; | 3940 return; |
3941 | 3941 |
3942 // |params.dst_rect| now contain values that reflect a potentially increased | 3942 // |params.dst_rect| now contain values that reflect a potentially increased |
3943 // size quad. | 3943 // size quad. |
3944 gfx::RectF updated_dst_rect = params.dst_rect; | 3944 gfx::RectF updated_dst_rect = params.dst_rect; |
3945 *new_bounds = updated_dst_rect; | 3945 |
| 3946 // Round the size of the IOSurface to a multiple of 64 pixels. This reduces |
| 3947 // memory fragmentation. https://crbug.com/146070. This also allows IOSurfaces |
| 3948 // to be more easily reused during a resize operation. |
| 3949 uint32_t iosurface_multiple = 64; |
| 3950 uint32_t iosurface_width = MathUtil::UncheckedRoundUp( |
| 3951 static_cast<uint32_t>(updated_dst_rect.width()), iosurface_multiple); |
| 3952 uint32_t iosurface_height = MathUtil::UncheckedRoundUp( |
| 3953 static_cast<uint32_t>(updated_dst_rect.height()), iosurface_multiple); |
| 3954 |
| 3955 *resource = overlay_resource_pool_->AcquireResource( |
| 3956 gfx::Size(iosurface_width, iosurface_height), ResourceFormat::RGBA_8888, |
| 3957 output_surface_->device_color_space()); |
| 3958 *new_bounds = |
| 3959 gfx::RectF(updated_dst_rect.x(), updated_dst_rect.y(), |
| 3960 (*resource)->size().width(), (*resource)->size().height()); |
3946 | 3961 |
3947 // Calculate new projection and window matrices for a minimally sized viewport | 3962 // Calculate new projection and window matrices for a minimally sized viewport |
3948 // using InitializeViewport(). This requires creating a dummy DrawingFrame. | 3963 // using InitializeViewport(). This requires creating a dummy DrawingFrame. |
3949 { | 3964 { |
3950 DrawingFrame frame; | 3965 DrawingFrame frame; |
3951 force_drawing_frame_framebuffer_unflipped_ = true; | 3966 force_drawing_frame_framebuffer_unflipped_ = true; |
3952 gfx::Rect frame_rect = | 3967 gfx::Rect frame_rect = |
3953 gfx::Rect(0, 0, updated_dst_rect.width(), updated_dst_rect.height()); | 3968 gfx::Rect(0, 0, updated_dst_rect.width(), updated_dst_rect.height()); |
3954 InitializeViewport(&frame, frame_rect, frame_rect, frame_rect.size()); | 3969 InitializeViewport(&frame, frame_rect, frame_rect, frame_rect.size()); |
3955 force_drawing_frame_framebuffer_unflipped_ = false; | 3970 force_drawing_frame_framebuffer_unflipped_ = false; |
(...skipping 19 matching lines...) Expand all Loading... |
3975 bool clipped = false; | 3990 bool clipped = false; |
3976 params.contents_device_transform.FlattenTo2d(); | 3991 params.contents_device_transform.FlattenTo2d(); |
3977 gfx::QuadF device_layer_quad = MathUtil::MapQuad( | 3992 gfx::QuadF device_layer_quad = MathUtil::MapQuad( |
3978 params.contents_device_transform, SharedGeometryQuad(), &clipped); | 3993 params.contents_device_transform, SharedGeometryQuad(), &clipped); |
3979 LayerQuad device_layer_edges(device_layer_quad); | 3994 LayerQuad device_layer_edges(device_layer_quad); |
3980 InflateAntiAliasingDistances(device_layer_quad, &device_layer_edges, | 3995 InflateAntiAliasingDistances(device_layer_quad, &device_layer_edges, |
3981 params.edge); | 3996 params.edge); |
3982 } | 3997 } |
3983 | 3998 |
3984 // Establish destination texture. | 3999 // Establish destination texture. |
3985 *resource = overlay_resource_pool_->AcquireResource( | |
3986 gfx::Size(updated_dst_rect.width(), updated_dst_rect.height()), | |
3987 ResourceFormat::RGBA_8888, output_surface_->device_color_space()); | |
3988 ResourceProvider::ScopedWriteLockGL destination(resource_provider_, | 4000 ResourceProvider::ScopedWriteLockGL destination(resource_provider_, |
3989 (*resource)->id(), false); | 4001 (*resource)->id(), false); |
3990 GLuint temp_fbo; | 4002 GLuint temp_fbo; |
3991 | 4003 |
3992 gl_->GenFramebuffers(1, &temp_fbo); | 4004 gl_->GenFramebuffers(1, &temp_fbo); |
3993 gl_->BindFramebuffer(GL_FRAMEBUFFER, temp_fbo); | 4005 gl_->BindFramebuffer(GL_FRAMEBUFFER, temp_fbo); |
3994 gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, | 4006 gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, |
3995 destination.target(), destination.texture_id(), 0); | 4007 destination.target(), destination.texture_id(), 0); |
3996 DCHECK(gl_->CheckFramebufferStatus(GL_FRAMEBUFFER) == | 4008 DCHECK(gl_->CheckFramebufferStatus(GL_FRAMEBUFFER) == |
3997 GL_FRAMEBUFFER_COMPLETE); | 4009 GL_FRAMEBUFFER_COMPLETE); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4061 | 4073 |
4062 gl_->ScheduleCALayerSharedStateCHROMIUM( | 4074 gl_->ScheduleCALayerSharedStateCHROMIUM( |
4063 ca_layer_overlay->shared_state->opacity, is_clipped, clip_rect, | 4075 ca_layer_overlay->shared_state->opacity, is_clipped, clip_rect, |
4064 sorting_context_id, gl_transform); | 4076 sorting_context_id, gl_transform); |
4065 gl_->ScheduleCALayerCHROMIUM( | 4077 gl_->ScheduleCALayerCHROMIUM( |
4066 texture_id, contents_rect, ca_layer_overlay->background_color, | 4078 texture_id, contents_rect, ca_layer_overlay->background_color, |
4067 ca_layer_overlay->edge_aa_mask, bounds_rect, filter); | 4079 ca_layer_overlay->edge_aa_mask, bounds_rect, filter); |
4068 } | 4080 } |
4069 | 4081 |
4070 } // namespace cc | 4082 } // namespace cc |
OLD | NEW |