Chromium Code Reviews| Index: content/browser/renderer_host/render_widget_host_view_aura.cc |
| diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc |
| index 0da585350faa3e1e3fd09dbd9c5df1c4a8cde9d5..ad8ba8188220cb1f1f54f3bbab447cf54fa0c0b9 100644 |
| --- a/content/browser/renderer_host/render_widget_host_view_aura.cc |
| +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc |
| @@ -632,6 +632,7 @@ RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host) |
| text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
| can_compose_inline_(true), |
| has_composition_text_(false), |
| + last_swapped_surface_scale_factor_(1.f), |
| paint_canvas_(NULL), |
| synthetic_move_sent_(false), |
| accelerated_compositing_state_changed_(false), |
| @@ -1195,7 +1196,9 @@ void RenderWidgetHostViewAura::CopyFromCompositingSurfaceHelper( |
| gfx::Rect src_subrect_in_gl = src_subrect; |
| src_subrect_in_gl.set_y(GetViewBounds().height() - src_subrect.bottom()); |
| - gfx::Rect src_subrect_in_pixel = ConvertRectToPixel(this, src_subrect_in_gl); |
| + gfx::Rect src_subrect_in_pixel = |
| + ConvertRectToPixel(current_surface_->device_scale_factor(), |
| + src_subrect_in_gl); |
| gl_helper->CropScaleReadbackAndCleanTexture( |
| current_surface_->PrepareTexture(), |
| current_surface_->size(), |
| @@ -1316,11 +1319,13 @@ void RenderWidgetHostViewAura::UpdateExternalTexture() { |
| bool is_compositing_active = host_->is_accelerated_compositing_active(); |
| if (is_compositing_active && current_surface_) { |
| window_->SetExternalTexture(current_surface_.get()); |
| - current_frame_size_ = ConvertSizeToDIP(this, current_surface_->size()); |
| + current_frame_size_ = ConvertSizeToDIP( |
| + current_surface_->device_scale_factor(), current_surface_->size()); |
| CheckResizeLock(); |
| } else if (is_compositing_active && current_dib_) { |
| window_->SetExternalTexture(NULL); |
| - current_frame_size_ = ConvertSizeToDIP(this, last_swapped_surface_size_); |
| + current_frame_size_ = ConvertSizeToDIP(last_swapped_surface_scale_factor_, |
| + last_swapped_surface_size_); |
| CheckResizeLock(); |
| } else { |
| window_->SetExternalTexture(NULL); |
| @@ -1331,6 +1336,7 @@ void RenderWidgetHostViewAura::UpdateExternalTexture() { |
| bool RenderWidgetHostViewAura::SwapBuffersPrepare( |
| const gfx::Rect& surface_rect, |
| + float surface_scale_factor, |
| const gfx::Rect& damage_rect, |
| const std::string& mailbox_name, |
| const BufferPresentedCallback& ack_callback) { |
| @@ -1340,9 +1346,11 @@ bool RenderWidgetHostViewAura::SwapBuffersPrepare( |
| DLOG_IF(ERROR, damage_rect != surface_rect) << "Expected full damage rect"; |
| skipped_damage_.setEmpty(); |
| last_swapped_surface_size_ = surface_rect.size(); |
| + last_swapped_surface_scale_factor_ = surface_scale_factor; |
| } |
| - if (ShouldSkipFrame(ConvertSizeToDIP(this, surface_rect.size())) || |
| + if (ShouldSkipFrame(ConvertSizeToDIP(surface_scale_factor, |
| + surface_rect.size())) || |
| mailbox_name.empty()) { |
| skipped_damage_.op(RectToSkIRect(damage_rect), SkRegion::kUnion_Op); |
| ack_callback.Run(true, scoped_refptr<ui::Texture>()); |
| @@ -1351,7 +1359,7 @@ bool RenderWidgetHostViewAura::SwapBuffersPrepare( |
| ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
| current_surface_ = |
| - factory->CreateTransportClient(current_device_scale_factor_); |
| + factory->CreateTransportClient(surface_scale_factor); |
| if (!current_surface_) { |
| LOG(ERROR) << "Failed to create ImageTransport texture"; |
| ack_callback.Run(true, scoped_refptr<ui::Texture>()); |
| @@ -1377,7 +1385,8 @@ void RenderWidgetHostViewAura::SwapBuffersCompleted( |
| if (frame_subscriber()->ShouldCaptureFrame(present_time, |
| &frame, &callback)) { |
| CopyFromCompositingSurfaceToVideoFrame( |
| - gfx::Rect(ConvertSizeToDIP(this, current_surface_->size())), |
| + gfx::Rect(ConvertSizeToDIP(current_surface_->device_scale_factor(), |
| + current_surface_->size())), |
| frame, |
| base::Bind(callback, present_time)); |
| } |
| @@ -1429,7 +1438,8 @@ void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( |
| gpu_host_id, |
| params_in_pixel.mailbox_name); |
| BuffersSwapped( |
| - params_in_pixel.size, params_in_pixel.mailbox_name, ack_callback); |
| + params_in_pixel.size, params_in_pixel.scale_factor, |
| + params_in_pixel.mailbox_name, ack_callback); |
| } |
| void RenderWidgetHostViewAura::SwapDelegatedFrame( |
| @@ -1497,6 +1507,7 @@ void RenderWidgetHostViewAura::SwapSoftwareFrame( |
| current_dib_.reset(dib.release()); |
| current_dib_id_ = dib_id; |
| last_swapped_surface_size_ = frame_size; |
| + last_swapped_surface_scale_factor_ = frame_device_scale_factor; |
| ui::Compositor* compositor = GetCompositor(); |
| if (!compositor) { |
| @@ -1519,7 +1530,8 @@ void RenderWidgetHostViewAura::SwapSoftwareFrame( |
| CheckResizeLock(); |
| released_front_lock_ = NULL; |
| window_->SetExternalTexture(NULL); |
| - window_->SchedulePaintInRect(ConvertRectToDIP(this, damage_rect)); |
| + window_->SchedulePaintInRect( |
| + ConvertRectToDIP(frame_device_scale_factor, damage_rect)); |
|
ccameron
2013/05/23 23:49:28
This looks to be an unrelated bug, but came up in
piman
2013/05/24 01:03:41
good catch.
|
| if (paint_observer_) |
| paint_observer_->OnUpdateCompositorContent(); |
| @@ -1568,17 +1580,19 @@ void RenderWidgetHostViewAura::OnSwapCompositorFrame( |
| reinterpret_cast<const char*>(frame->gl_frame_data->mailbox.name), |
| sizeof(frame->gl_frame_data->mailbox.name)); |
| BuffersSwapped( |
| - frame->gl_frame_data->size, mailbox_name, ack_callback); |
| + frame->gl_frame_data->size, frame->metadata.device_scale_factor, |
| + mailbox_name, ack_callback); |
| } |
| void RenderWidgetHostViewAura::BuffersSwapped( |
| const gfx::Size& size, |
| + float surface_scale_factor, |
| const std::string& mailbox_name, |
| const BufferPresentedCallback& ack_callback) { |
| scoped_refptr<ui::Texture> texture_to_return(current_surface_); |
| const gfx::Rect surface_rect = gfx::Rect(size); |
| - if (!SwapBuffersPrepare( |
| - surface_rect, surface_rect, mailbox_name, ack_callback)) { |
| + if (!SwapBuffersPrepare(surface_rect, surface_scale_factor, surface_rect, |
| + mailbox_name, ack_callback)) { |
| return; |
| } |
| @@ -1587,7 +1601,7 @@ void RenderWidgetHostViewAura::BuffersSwapped( |
| ui::Compositor* compositor = GetCompositor(); |
| if (compositor) { |
| - gfx::Size surface_size = ConvertSizeToDIP(this, size); |
| + gfx::Size surface_size = ConvertSizeToDIP(surface_scale_factor, size); |
| window_->SchedulePaintInRect(gfx::Rect(surface_size)); |
| } |
| @@ -1612,7 +1626,8 @@ void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( |
| params_in_pixel.mailbox_name); |
| if (!SwapBuffersPrepare( |
| - surface_rect, damage_rect, params_in_pixel.mailbox_name, ack_callback)) { |
| + surface_rect, params_in_pixel.surface_scale_factor, damage_rect, |
| + params_in_pixel.mailbox_name, ack_callback)) { |
| return; |
| } |
| @@ -1646,12 +1661,13 @@ void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( |
| if (compositor) { |
| // Co-ordinates come in OpenGL co-ordinate space. |
| // We need to convert to layer space. |
| - gfx::Rect rect_to_paint = ConvertRectToDIP(this, gfx::Rect( |
| - params_in_pixel.x, |
| - surface_size_in_pixel.height() - params_in_pixel.y - |
| - params_in_pixel.height, |
| - params_in_pixel.width, |
| - params_in_pixel.height)); |
| + gfx::Rect rect_to_paint = ConvertRectToDIP( |
| + params_in_pixel.surface_scale_factor, |
| + gfx::Rect(params_in_pixel.x, |
| + surface_size_in_pixel.height() - params_in_pixel.y - |
| + params_in_pixel.height, |
| + params_in_pixel.width, |
| + params_in_pixel.height)); |
| // Damage may not have been DIP aligned, so inflate damage to compensate |
| // for any round-off error. |
| @@ -2228,7 +2244,8 @@ scoped_refptr<ui::Texture> RenderWidgetHostViewAura::CopyTexture() { |
| return scoped_refptr<ui::Texture>( |
| factory->CreateOwnedTexture( |
| - current_surface_->size(), current_device_scale_factor_, texture_id)); |
| + current_surface_->size(), |
| + current_surface_->device_scale_factor(), texture_id)); |
| } |
| //////////////////////////////////////////////////////////////////////////////// |