Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_aura.cc

Issue 15666007: Use correct device scale factors in Aura (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/renderer_host/render_widget_host_view_aura.h" 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 : host_(RenderWidgetHostImpl::From(host)), 625 : host_(RenderWidgetHostImpl::From(host)),
626 window_(new aura::Window(this)), 626 window_(new aura::Window(this)),
627 in_shutdown_(false), 627 in_shutdown_(false),
628 is_fullscreen_(false), 628 is_fullscreen_(false),
629 popup_parent_host_view_(NULL), 629 popup_parent_host_view_(NULL),
630 popup_child_host_view_(NULL), 630 popup_child_host_view_(NULL),
631 is_loading_(false), 631 is_loading_(false),
632 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), 632 text_input_type_(ui::TEXT_INPUT_TYPE_NONE),
633 can_compose_inline_(true), 633 can_compose_inline_(true),
634 has_composition_text_(false), 634 has_composition_text_(false),
635 last_swapped_surface_scale_factor_(1.f),
635 paint_canvas_(NULL), 636 paint_canvas_(NULL),
636 synthetic_move_sent_(false), 637 synthetic_move_sent_(false),
637 accelerated_compositing_state_changed_(false), 638 accelerated_compositing_state_changed_(false),
638 can_lock_compositor_(YES), 639 can_lock_compositor_(YES),
639 cursor_visibility_state_in_renderer_(UNKNOWN), 640 cursor_visibility_state_in_renderer_(UNKNOWN),
640 paint_observer_(NULL), 641 paint_observer_(NULL),
641 touch_editing_client_(NULL) { 642 touch_editing_client_(NULL) {
642 host_->SetView(this); 643 host_->SetView(this);
643 window_observer_.reset(new WindowObserver(this)); 644 window_observer_.reset(new WindowObserver(this));
644 aura::client::SetTooltipText(window_, &tooltip_); 645 aura::client::SetTooltipText(window_, &tooltip_);
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 AsWeakPtr(), 1189 AsWeakPtr(),
1189 output, 1190 output,
1190 callback); 1191 callback);
1191 ++pending_thumbnail_tasks_; 1192 ++pending_thumbnail_tasks_;
1192 1193
1193 // Convert |src_subrect| from the views coordinate (upper-left origin) into 1194 // Convert |src_subrect| from the views coordinate (upper-left origin) into
1194 // the OpenGL coordinate (lower-left origin). 1195 // the OpenGL coordinate (lower-left origin).
1195 gfx::Rect src_subrect_in_gl = src_subrect; 1196 gfx::Rect src_subrect_in_gl = src_subrect;
1196 src_subrect_in_gl.set_y(GetViewBounds().height() - src_subrect.bottom()); 1197 src_subrect_in_gl.set_y(GetViewBounds().height() - src_subrect.bottom());
1197 1198
1198 gfx::Rect src_subrect_in_pixel = ConvertRectToPixel(this, src_subrect_in_gl); 1199 gfx::Rect src_subrect_in_pixel =
1200 ConvertRectToPixel(current_surface_->device_scale_factor(),
1201 src_subrect_in_gl);
1199 gl_helper->CropScaleReadbackAndCleanTexture( 1202 gl_helper->CropScaleReadbackAndCleanTexture(
1200 current_surface_->PrepareTexture(), 1203 current_surface_->PrepareTexture(),
1201 current_surface_->size(), 1204 current_surface_->size(),
1202 src_subrect_in_pixel, 1205 src_subrect_in_pixel,
1203 dst_size_in_pixel, 1206 dst_size_in_pixel,
1204 addr, 1207 addr,
1205 wrapper_callback); 1208 wrapper_callback);
1206 } 1209 }
1207 1210
1208 void RenderWidgetHostViewAura::CopyFromCompositingSurface( 1211 void RenderWidgetHostViewAura::CopyFromCompositingSurface(
1209 const gfx::Rect& src_subrect, 1212 const gfx::Rect& src_subrect,
1210 const gfx::Size& dst_size, 1213 const gfx::Size& dst_size,
1211 const base::Callback<void(bool, const SkBitmap&)>& callback) { 1214 const base::Callback<void(bool, const SkBitmap&)>& callback) {
1212 if (!current_surface_) { 1215 if (!current_surface_) {
1213 callback.Run(false, SkBitmap()); 1216 callback.Run(false, SkBitmap());
1214 return; 1217 return;
1215 } 1218 }
1216 1219
1217 CopyFromCompositingSurfaceHelper(src_subrect, 1220 CopyFromCompositingSurfaceHelper(src_subrect,
1218 ConvertSizeToPixel(this, dst_size), 1221 ConvertSizeToPixel(this, dst_size),
ccameron 2013/05/23 23:49:28 This is the only remaining instance where we use t
piman 2013/05/24 01:03:41 SGTM. The dst_size passed here is in DIP and is in
1219 callback); 1222 callback);
1220 } 1223 }
1221 1224
1222 void RenderWidgetHostViewAura::CopyFromCompositingSurfaceToVideoFrame( 1225 void RenderWidgetHostViewAura::CopyFromCompositingSurfaceToVideoFrame(
1223 const gfx::Rect& src_subrect, 1226 const gfx::Rect& src_subrect,
1224 const scoped_refptr<media::VideoFrame>& target, 1227 const scoped_refptr<media::VideoFrame>& target,
1225 const base::Callback<void(bool)>& callback) { 1228 const base::Callback<void(bool)>& callback) {
1226 base::ScopedClosureRunner scoped_callback_runner(base::Bind(callback, false)); 1229 base::ScopedClosureRunner scoped_callback_runner(base::Bind(callback, false));
1227 1230
1228 if (!current_surface_) 1231 if (!current_surface_)
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1309 void RenderWidgetHostViewAura::UpdateExternalTexture() { 1312 void RenderWidgetHostViewAura::UpdateExternalTexture() {
1310 // Delay processing accelerated compositing state change till here where we 1313 // Delay processing accelerated compositing state change till here where we
1311 // act upon the state change. (Clear the external texture if switching to 1314 // act upon the state change. (Clear the external texture if switching to
1312 // software mode or set the external texture if going to accelerated mode). 1315 // software mode or set the external texture if going to accelerated mode).
1313 if (accelerated_compositing_state_changed_) 1316 if (accelerated_compositing_state_changed_)
1314 accelerated_compositing_state_changed_ = false; 1317 accelerated_compositing_state_changed_ = false;
1315 1318
1316 bool is_compositing_active = host_->is_accelerated_compositing_active(); 1319 bool is_compositing_active = host_->is_accelerated_compositing_active();
1317 if (is_compositing_active && current_surface_) { 1320 if (is_compositing_active && current_surface_) {
1318 window_->SetExternalTexture(current_surface_.get()); 1321 window_->SetExternalTexture(current_surface_.get());
1319 current_frame_size_ = ConvertSizeToDIP(this, current_surface_->size()); 1322 current_frame_size_ = ConvertSizeToDIP(
1323 current_surface_->device_scale_factor(), current_surface_->size());
1320 CheckResizeLock(); 1324 CheckResizeLock();
1321 } else if (is_compositing_active && current_dib_) { 1325 } else if (is_compositing_active && current_dib_) {
1322 window_->SetExternalTexture(NULL); 1326 window_->SetExternalTexture(NULL);
1323 current_frame_size_ = ConvertSizeToDIP(this, last_swapped_surface_size_); 1327 current_frame_size_ = ConvertSizeToDIP(last_swapped_surface_scale_factor_,
1328 last_swapped_surface_size_);
1324 CheckResizeLock(); 1329 CheckResizeLock();
1325 } else { 1330 } else {
1326 window_->SetExternalTexture(NULL); 1331 window_->SetExternalTexture(NULL);
1327 resize_lock_.reset(); 1332 resize_lock_.reset();
1328 host_->WasResized(); 1333 host_->WasResized();
1329 } 1334 }
1330 } 1335 }
1331 1336
1332 bool RenderWidgetHostViewAura::SwapBuffersPrepare( 1337 bool RenderWidgetHostViewAura::SwapBuffersPrepare(
1333 const gfx::Rect& surface_rect, 1338 const gfx::Rect& surface_rect,
1339 float surface_scale_factor,
1334 const gfx::Rect& damage_rect, 1340 const gfx::Rect& damage_rect,
1335 const std::string& mailbox_name, 1341 const std::string& mailbox_name,
1336 const BufferPresentedCallback& ack_callback) { 1342 const BufferPresentedCallback& ack_callback) {
1337 if (last_swapped_surface_size_ != surface_rect.size()) { 1343 if (last_swapped_surface_size_ != surface_rect.size()) {
1338 // The surface could have shrunk since we skipped an update, in which 1344 // The surface could have shrunk since we skipped an update, in which
1339 // case we can expect a full update. 1345 // case we can expect a full update.
1340 DLOG_IF(ERROR, damage_rect != surface_rect) << "Expected full damage rect"; 1346 DLOG_IF(ERROR, damage_rect != surface_rect) << "Expected full damage rect";
1341 skipped_damage_.setEmpty(); 1347 skipped_damage_.setEmpty();
1342 last_swapped_surface_size_ = surface_rect.size(); 1348 last_swapped_surface_size_ = surface_rect.size();
1349 last_swapped_surface_scale_factor_ = surface_scale_factor;
1343 } 1350 }
1344 1351
1345 if (ShouldSkipFrame(ConvertSizeToDIP(this, surface_rect.size())) || 1352 if (ShouldSkipFrame(ConvertSizeToDIP(surface_scale_factor,
1353 surface_rect.size())) ||
1346 mailbox_name.empty()) { 1354 mailbox_name.empty()) {
1347 skipped_damage_.op(RectToSkIRect(damage_rect), SkRegion::kUnion_Op); 1355 skipped_damage_.op(RectToSkIRect(damage_rect), SkRegion::kUnion_Op);
1348 ack_callback.Run(true, scoped_refptr<ui::Texture>()); 1356 ack_callback.Run(true, scoped_refptr<ui::Texture>());
1349 return false; 1357 return false;
1350 } 1358 }
1351 1359
1352 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 1360 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
1353 current_surface_ = 1361 current_surface_ =
1354 factory->CreateTransportClient(current_device_scale_factor_); 1362 factory->CreateTransportClient(surface_scale_factor);
1355 if (!current_surface_) { 1363 if (!current_surface_) {
1356 LOG(ERROR) << "Failed to create ImageTransport texture"; 1364 LOG(ERROR) << "Failed to create ImageTransport texture";
1357 ack_callback.Run(true, scoped_refptr<ui::Texture>()); 1365 ack_callback.Run(true, scoped_refptr<ui::Texture>());
1358 return false; 1366 return false;
1359 } 1367 }
1360 1368
1361 current_surface_->Consume(mailbox_name, surface_rect.size()); 1369 current_surface_->Consume(mailbox_name, surface_rect.size());
1362 released_front_lock_ = NULL; 1370 released_front_lock_ = NULL;
1363 UpdateExternalTexture(); 1371 UpdateExternalTexture();
1364 1372
1365 return true; 1373 return true;
1366 } 1374 }
1367 1375
1368 void RenderWidgetHostViewAura::SwapBuffersCompleted( 1376 void RenderWidgetHostViewAura::SwapBuffersCompleted(
1369 const BufferPresentedCallback& ack_callback, 1377 const BufferPresentedCallback& ack_callback,
1370 const scoped_refptr<ui::Texture>& texture_to_return) { 1378 const scoped_refptr<ui::Texture>& texture_to_return) {
1371 ui::Compositor* compositor = GetCompositor(); 1379 ui::Compositor* compositor = GetCompositor();
1372 1380
1373 if (frame_subscriber() && current_surface_ != NULL) { 1381 if (frame_subscriber() && current_surface_ != NULL) {
1374 const base::Time present_time = base::Time::Now(); 1382 const base::Time present_time = base::Time::Now();
1375 scoped_refptr<media::VideoFrame> frame; 1383 scoped_refptr<media::VideoFrame> frame;
1376 RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback callback; 1384 RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback callback;
1377 if (frame_subscriber()->ShouldCaptureFrame(present_time, 1385 if (frame_subscriber()->ShouldCaptureFrame(present_time,
1378 &frame, &callback)) { 1386 &frame, &callback)) {
1379 CopyFromCompositingSurfaceToVideoFrame( 1387 CopyFromCompositingSurfaceToVideoFrame(
1380 gfx::Rect(ConvertSizeToDIP(this, current_surface_->size())), 1388 gfx::Rect(ConvertSizeToDIP(current_surface_->device_scale_factor(),
1389 current_surface_->size())),
1381 frame, 1390 frame,
1382 base::Bind(callback, present_time)); 1391 base::Bind(callback, present_time));
1383 } 1392 }
1384 } 1393 }
1385 1394
1386 if (!compositor) { 1395 if (!compositor) {
1387 ack_callback.Run(false, texture_to_return); 1396 ack_callback.Run(false, texture_to_return);
1388 } else { 1397 } else {
1389 AddOnCommitCallbackAndDisableLocks( 1398 AddOnCommitCallbackAndDisableLocks(
1390 base::Bind(ack_callback, false, texture_to_return)); 1399 base::Bind(ack_callback, false, texture_to_return));
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1422 1431
1423 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( 1432 void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped(
1424 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel, 1433 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params_in_pixel,
1425 int gpu_host_id) { 1434 int gpu_host_id) {
1426 BufferPresentedCallback ack_callback = base::Bind( 1435 BufferPresentedCallback ack_callback = base::Bind(
1427 &AcknowledgeBufferForGpu, 1436 &AcknowledgeBufferForGpu,
1428 params_in_pixel.route_id, 1437 params_in_pixel.route_id,
1429 gpu_host_id, 1438 gpu_host_id,
1430 params_in_pixel.mailbox_name); 1439 params_in_pixel.mailbox_name);
1431 BuffersSwapped( 1440 BuffersSwapped(
1432 params_in_pixel.size, params_in_pixel.mailbox_name, ack_callback); 1441 params_in_pixel.size, params_in_pixel.scale_factor,
1442 params_in_pixel.mailbox_name, ack_callback);
1433 } 1443 }
1434 1444
1435 void RenderWidgetHostViewAura::SwapDelegatedFrame( 1445 void RenderWidgetHostViewAura::SwapDelegatedFrame(
1436 scoped_ptr<cc::DelegatedFrameData> frame_data, 1446 scoped_ptr<cc::DelegatedFrameData> frame_data,
1437 float frame_device_scale_factor) { 1447 float frame_device_scale_factor) {
1438 gfx::Size frame_size_in_dip; 1448 gfx::Size frame_size_in_dip;
1439 if (!frame_data->render_pass_list.empty()) { 1449 if (!frame_data->render_pass_list.empty()) {
1440 frame_size_in_dip = gfx::ToFlooredSize(gfx::ScaleSize( 1450 frame_size_in_dip = gfx::ToFlooredSize(gfx::ScaleSize(
1441 frame_data->render_pass_list.back()->output_rect.size(), 1451 frame_data->render_pass_list.back()->output_rect.size(),
1442 1.f/frame_device_scale_factor)); 1452 1.f/frame_device_scale_factor));
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1490 1500
1491 if (last_swapped_surface_size_ != frame_size) { 1501 if (last_swapped_surface_size_ != frame_size) {
1492 DLOG_IF(ERROR, damage_rect != gfx::Rect(frame_size)) 1502 DLOG_IF(ERROR, damage_rect != gfx::Rect(frame_size))
1493 << "Expected full damage rect"; 1503 << "Expected full damage rect";
1494 } 1504 }
1495 1505
1496 TransportDIB::Id last_dib_id = current_dib_id_; 1506 TransportDIB::Id last_dib_id = current_dib_id_;
1497 current_dib_.reset(dib.release()); 1507 current_dib_.reset(dib.release());
1498 current_dib_id_ = dib_id; 1508 current_dib_id_ = dib_id;
1499 last_swapped_surface_size_ = frame_size; 1509 last_swapped_surface_size_ = frame_size;
1510 last_swapped_surface_scale_factor_ = frame_device_scale_factor;
1500 1511
1501 ui::Compositor* compositor = GetCompositor(); 1512 ui::Compositor* compositor = GetCompositor();
1502 if (!compositor) { 1513 if (!compositor) {
1503 SendSoftwareFrameAck(last_dib_id); 1514 SendSoftwareFrameAck(last_dib_id);
1504 return; 1515 return;
1505 } 1516 }
1506 1517
1507 gfx::Size frame_size_in_dip = gfx::ToFlooredSize( 1518 gfx::Size frame_size_in_dip = gfx::ToFlooredSize(
1508 gfx::ScaleSize(frame_size, 1.0f / frame_device_scale_factor)); 1519 gfx::ScaleSize(frame_size, 1.0f / frame_device_scale_factor));
piman 2013/05/24 01:03:41 nit: could use the new version of ConvertSizeToDIP
ccameron 2013/05/24 09:45:03 Done.
1509 if (ShouldSkipFrame(frame_size_in_dip)) { 1520 if (ShouldSkipFrame(frame_size_in_dip)) {
1510 can_lock_compositor_ = NO_PENDING_COMMIT; 1521 can_lock_compositor_ = NO_PENDING_COMMIT;
1511 SendSoftwareFrameAck(last_dib_id); 1522 SendSoftwareFrameAck(last_dib_id);
1512 } else { 1523 } else {
1513 AddOnCommitCallbackAndDisableLocks( 1524 AddOnCommitCallbackAndDisableLocks(
1514 base::Bind(&RenderWidgetHostViewAura::SendSoftwareFrameAck, 1525 base::Bind(&RenderWidgetHostViewAura::SendSoftwareFrameAck,
1515 AsWeakPtr(), last_dib_id)); 1526 AsWeakPtr(), last_dib_id));
1516 } 1527 }
1517 1528
1518 current_frame_size_ = frame_size_in_dip; 1529 current_frame_size_ = frame_size_in_dip;
1519 CheckResizeLock(); 1530 CheckResizeLock();
1520 released_front_lock_ = NULL; 1531 released_front_lock_ = NULL;
1521 window_->SetExternalTexture(NULL); 1532 window_->SetExternalTexture(NULL);
1522 window_->SchedulePaintInRect(ConvertRectToDIP(this, damage_rect)); 1533 window_->SchedulePaintInRect(
1534 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.
1523 1535
1524 if (paint_observer_) 1536 if (paint_observer_)
1525 paint_observer_->OnUpdateCompositorContent(); 1537 paint_observer_->OnUpdateCompositorContent();
1526 } 1538 }
1527 1539
1528 void RenderWidgetHostViewAura::SendSoftwareFrameAck( 1540 void RenderWidgetHostViewAura::SendSoftwareFrameAck(
1529 const TransportDIB::Id& id) { 1541 const TransportDIB::Id& id) {
1530 cc::CompositorFrameAck ack; 1542 cc::CompositorFrameAck ack;
1531 ack.last_dib_id = id; 1543 ack.last_dib_id = id;
1532 RenderWidgetHostImpl::SendSwapCompositorFrameAck( 1544 RenderWidgetHostImpl::SendSwapCompositorFrameAck(
(...skipping 28 matching lines...) Expand all
1561 return; 1573 return;
1562 } 1574 }
1563 1575
1564 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); 1576 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
1565 factory->WaitSyncPoint(frame->gl_frame_data->sync_point); 1577 factory->WaitSyncPoint(frame->gl_frame_data->sync_point);
1566 1578
1567 std::string mailbox_name( 1579 std::string mailbox_name(
1568 reinterpret_cast<const char*>(frame->gl_frame_data->mailbox.name), 1580 reinterpret_cast<const char*>(frame->gl_frame_data->mailbox.name),
1569 sizeof(frame->gl_frame_data->mailbox.name)); 1581 sizeof(frame->gl_frame_data->mailbox.name));
1570 BuffersSwapped( 1582 BuffersSwapped(
1571 frame->gl_frame_data->size, mailbox_name, ack_callback); 1583 frame->gl_frame_data->size, frame->metadata.device_scale_factor,
1584 mailbox_name, ack_callback);
1572 } 1585 }
1573 1586
1574 void RenderWidgetHostViewAura::BuffersSwapped( 1587 void RenderWidgetHostViewAura::BuffersSwapped(
1575 const gfx::Size& size, 1588 const gfx::Size& size,
1589 float surface_scale_factor,
1576 const std::string& mailbox_name, 1590 const std::string& mailbox_name,
1577 const BufferPresentedCallback& ack_callback) { 1591 const BufferPresentedCallback& ack_callback) {
1578 scoped_refptr<ui::Texture> texture_to_return(current_surface_); 1592 scoped_refptr<ui::Texture> texture_to_return(current_surface_);
1579 const gfx::Rect surface_rect = gfx::Rect(size); 1593 const gfx::Rect surface_rect = gfx::Rect(size);
1580 if (!SwapBuffersPrepare( 1594 if (!SwapBuffersPrepare(surface_rect, surface_scale_factor, surface_rect,
1581 surface_rect, surface_rect, mailbox_name, ack_callback)) { 1595 mailbox_name, ack_callback)) {
1582 return; 1596 return;
1583 } 1597 }
1584 1598
1585 previous_damage_.setRect(RectToSkIRect(surface_rect)); 1599 previous_damage_.setRect(RectToSkIRect(surface_rect));
1586 skipped_damage_.setEmpty(); 1600 skipped_damage_.setEmpty();
1587 1601
1588 ui::Compositor* compositor = GetCompositor(); 1602 ui::Compositor* compositor = GetCompositor();
1589 if (compositor) { 1603 if (compositor) {
1590 gfx::Size surface_size = ConvertSizeToDIP(this, size); 1604 gfx::Size surface_size = ConvertSizeToDIP(surface_scale_factor, size);
1591 window_->SchedulePaintInRect(gfx::Rect(surface_size)); 1605 window_->SchedulePaintInRect(gfx::Rect(surface_size));
1592 } 1606 }
1593 1607
1594 if (paint_observer_) 1608 if (paint_observer_)
1595 paint_observer_->OnUpdateCompositorContent(); 1609 paint_observer_->OnUpdateCompositorContent();
1596 1610
1597 SwapBuffersCompleted(ack_callback, texture_to_return); 1611 SwapBuffersCompleted(ack_callback, texture_to_return);
1598 } 1612 }
1599 1613
1600 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( 1614 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer(
1601 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, 1615 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel,
1602 int gpu_host_id) { 1616 int gpu_host_id) {
1603 scoped_refptr<ui::Texture> previous_texture(current_surface_); 1617 scoped_refptr<ui::Texture> previous_texture(current_surface_);
1604 const gfx::Rect surface_rect = 1618 const gfx::Rect surface_rect =
1605 gfx::Rect(params_in_pixel.surface_size); 1619 gfx::Rect(params_in_pixel.surface_size);
1606 gfx::Rect damage_rect(params_in_pixel.x, 1620 gfx::Rect damage_rect(params_in_pixel.x,
1607 params_in_pixel.y, 1621 params_in_pixel.y,
1608 params_in_pixel.width, 1622 params_in_pixel.width,
1609 params_in_pixel.height); 1623 params_in_pixel.height);
1610 BufferPresentedCallback ack_callback = base::Bind( 1624 BufferPresentedCallback ack_callback = base::Bind(
1611 &AcknowledgeBufferForGpu, params_in_pixel.route_id, gpu_host_id, 1625 &AcknowledgeBufferForGpu, params_in_pixel.route_id, gpu_host_id,
1612 params_in_pixel.mailbox_name); 1626 params_in_pixel.mailbox_name);
1613 1627
1614 if (!SwapBuffersPrepare( 1628 if (!SwapBuffersPrepare(
1615 surface_rect, damage_rect, params_in_pixel.mailbox_name, ack_callback)) { 1629 surface_rect, params_in_pixel.surface_scale_factor, damage_rect,
1630 params_in_pixel.mailbox_name, ack_callback)) {
1616 return; 1631 return;
1617 } 1632 }
1618 1633
1619 SkRegion damage(RectToSkIRect(damage_rect)); 1634 SkRegion damage(RectToSkIRect(damage_rect));
1620 if (!skipped_damage_.isEmpty()) { 1635 if (!skipped_damage_.isEmpty()) {
1621 damage.op(skipped_damage_, SkRegion::kUnion_Op); 1636 damage.op(skipped_damage_, SkRegion::kUnion_Op);
1622 skipped_damage_.setEmpty(); 1637 skipped_damage_.setEmpty();
1623 } 1638 }
1624 1639
1625 DCHECK(surface_rect.Contains(SkIRectToRect(damage.getBounds()))); 1640 DCHECK(surface_rect.Contains(SkIRectToRect(damage.getBounds())));
(...skipping 13 matching lines...) Expand all
1639 previous_texture->PrepareTexture(), 1654 previous_texture->PrepareTexture(),
1640 damage, 1655 damage,
1641 previous_damage_); 1656 previous_damage_);
1642 } 1657 }
1643 previous_damage_ = damage; 1658 previous_damage_ = damage;
1644 1659
1645 ui::Compositor* compositor = GetCompositor(); 1660 ui::Compositor* compositor = GetCompositor();
1646 if (compositor) { 1661 if (compositor) {
1647 // Co-ordinates come in OpenGL co-ordinate space. 1662 // Co-ordinates come in OpenGL co-ordinate space.
1648 // We need to convert to layer space. 1663 // We need to convert to layer space.
1649 gfx::Rect rect_to_paint = ConvertRectToDIP(this, gfx::Rect( 1664 gfx::Rect rect_to_paint = ConvertRectToDIP(
1650 params_in_pixel.x, 1665 params_in_pixel.surface_scale_factor,
1651 surface_size_in_pixel.height() - params_in_pixel.y - 1666 gfx::Rect(params_in_pixel.x,
1652 params_in_pixel.height, 1667 surface_size_in_pixel.height() - params_in_pixel.y -
1653 params_in_pixel.width, 1668 params_in_pixel.height,
1654 params_in_pixel.height)); 1669 params_in_pixel.width,
1670 params_in_pixel.height));
1655 1671
1656 // Damage may not have been DIP aligned, so inflate damage to compensate 1672 // Damage may not have been DIP aligned, so inflate damage to compensate
1657 // for any round-off error. 1673 // for any round-off error.
1658 rect_to_paint.Inset(-1, -1); 1674 rect_to_paint.Inset(-1, -1);
1659 rect_to_paint.Intersect(window_->bounds()); 1675 rect_to_paint.Intersect(window_->bounds());
1660 1676
1661 if (paint_observer_) 1677 if (paint_observer_)
1662 paint_observer_->OnUpdateCompositorContent(); 1678 paint_observer_->OnUpdateCompositorContent();
1663 window_->SchedulePaintInRect(rect_to_paint); 1679 window_->SchedulePaintInRect(rect_to_paint);
1664 } 1680 }
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
2221 return scoped_refptr<ui::Texture>(); 2237 return scoped_refptr<ui::Texture>();
2222 2238
2223 WebKit::WebGLId texture_id = 2239 WebKit::WebGLId texture_id =
2224 gl_helper->CopyTexture(current_surface_->PrepareTexture(), 2240 gl_helper->CopyTexture(current_surface_->PrepareTexture(),
2225 current_surface_->size()); 2241 current_surface_->size());
2226 if (!texture_id) 2242 if (!texture_id)
2227 return scoped_refptr<ui::Texture>(); 2243 return scoped_refptr<ui::Texture>();
2228 2244
2229 return scoped_refptr<ui::Texture>( 2245 return scoped_refptr<ui::Texture>(
2230 factory->CreateOwnedTexture( 2246 factory->CreateOwnedTexture(
2231 current_surface_->size(), current_device_scale_factor_, texture_id)); 2247 current_surface_->size(),
2248 current_surface_->device_scale_factor(), texture_id));
2232 } 2249 }
2233 2250
2234 //////////////////////////////////////////////////////////////////////////////// 2251 ////////////////////////////////////////////////////////////////////////////////
2235 // RenderWidgetHostViewAura, ui::EventHandler implementation: 2252 // RenderWidgetHostViewAura, ui::EventHandler implementation:
2236 2253
2237 void RenderWidgetHostViewAura::OnKeyEvent(ui::KeyEvent* event) { 2254 void RenderWidgetHostViewAura::OnKeyEvent(ui::KeyEvent* event) {
2238 TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnKeyEvent"); 2255 TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnKeyEvent");
2239 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event)) 2256 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event))
2240 return; 2257 return;
2241 2258
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after
2956 RenderWidgetHost* widget) { 2973 RenderWidgetHost* widget) {
2957 return new RenderWidgetHostViewAura(widget); 2974 return new RenderWidgetHostViewAura(widget);
2958 } 2975 }
2959 2976
2960 // static 2977 // static
2961 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { 2978 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) {
2962 GetScreenInfoForWindow(results, NULL); 2979 GetScreenInfoForWindow(results, NULL);
2963 } 2980 }
2964 2981
2965 } // namespace content 2982 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698