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

Side by Side Diff: content/renderer/pepper/pepper_graphics_2d_host.cc

Issue 1964423003: Apply viewport to dip scale to Graphics2D, Compositor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed comments Created 4 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
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/renderer/pepper/pepper_graphics_2d_host.h" 5 #include "content/renderer/pepper/pepper_graphics_2d_host.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 } 646 }
647 647
648 // For correctness with accelerated compositing, we must issue an invalidate 648 // For correctness with accelerated compositing, we must issue an invalidate
649 // on the full op_rect even if it is partially or completely off-screen. 649 // on the full op_rect even if it is partially or completely off-screen.
650 // However, if we issue an invalidate for a clipped-out region, WebKit will 650 // However, if we issue an invalidate for a clipped-out region, WebKit will
651 // do nothing and we won't get any ViewFlushedPaint calls, leaving our 651 // do nothing and we won't get any ViewFlushedPaint calls, leaving our
652 // callback stranded. So we still need to check whether the repainted area 652 // callback stranded. So we still need to check whether the repainted area
653 // is visible to determine how to deal with the callback. 653 // is visible to determine how to deal with the callback.
654 if (bound_instance_ && !op_rect.IsEmpty()) { 654 if (bound_instance_ && !op_rect.IsEmpty()) {
655 gfx::Point scroll_delta(operation.scroll_dx, operation.scroll_dy); 655 gfx::Point scroll_delta(operation.scroll_dx, operation.scroll_dy);
656 if (!ConvertToLogicalPixels(scale_, 656 // In use-zoom-for-dsf mode, the viewport (thus cc) uses native
657 &op_rect, 657 // pixels, so the damage and rects have to be scaled.
658 gfx::Rect op_rect_in_viewport = op_rect;
659 ConvertToLogicalPixels(scale_, &op_rect, nullptr);
660 if (!ConvertToLogicalPixels(scale_ / viewport_to_dip_scale_,
661 &op_rect_in_viewport,
658 operation.type == QueuedOperation::SCROLL 662 operation.type == QueuedOperation::SCROLL
659 ? &scroll_delta 663 ? &scroll_delta
660 : NULL)) { 664 : nullptr)) {
661 // Conversion requires falling back to InvalidateRect. 665 // Conversion requires falling back to InvalidateRect.
662 operation.type = QueuedOperation::PAINT; 666 operation.type = QueuedOperation::PAINT;
663 } 667 }
664 668
665 gfx::Rect clip = PP_ToGfxRect(bound_instance_->view_data().clip_rect); 669 gfx::Rect clip = PP_ToGfxRect(bound_instance_->view_data().clip_rect);
666 is_plugin_visible = !clip.IsEmpty(); 670 is_plugin_visible = !clip.IsEmpty();
667 671
668 // Set |no_update_visible| to false if the change overlaps the visible 672 // Set |no_update_visible| to false if the change overlaps the visible
669 // area. 673 // area.
670 if (!gfx::IntersectRects(clip, op_rect).IsEmpty()) { 674 if (!gfx::IntersectRects(clip, op_rect).IsEmpty()) {
671 no_update_visible = false; 675 no_update_visible = false;
672 } 676 }
673 677
674 // Notify the plugin of the entire change (op_rect), even if it is 678 // Notify the plugin of the entire change (op_rect), even if it is
675 // partially or completely off-screen. 679 // partially or completely off-screen.
676 if (operation.type == QueuedOperation::SCROLL) { 680 if (operation.type == QueuedOperation::SCROLL) {
677 bound_instance_->ScrollRect( 681 bound_instance_->ScrollRect(
678 scroll_delta.x(), scroll_delta.y(), op_rect); 682 scroll_delta.x(), scroll_delta.y(), op_rect_in_viewport);
679 } else { 683 } else {
680 if (!op_rect.IsEmpty()) 684 if (!op_rect_in_viewport.IsEmpty())
681 bound_instance_->InvalidateRect(op_rect); 685 bound_instance_->InvalidateRect(op_rect_in_viewport);
682 } 686 }
683 texture_mailbox_modified_ = true; 687 texture_mailbox_modified_ = true;
684 } 688 }
685 } 689 }
686 queued_operations_.clear(); 690 queued_operations_.clear();
687 691
688 if (!bound_instance_) { 692 if (!bound_instance_) {
689 // As promised in the API, we always schedule callback when unbound. 693 // As promised in the API, we always schedule callback when unbound.
690 ScheduleOffscreenFlushAck(); 694 ScheduleOffscreenFlushAck();
691 } else if (no_update_visible && is_plugin_visible && 695 } else if (no_update_visible && is_plugin_visible &&
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 gfx::Point inverse_scaled_point = 835 gfx::Point inverse_scaled_point =
832 gfx::ScaleToFlooredPoint(*delta, inverse_scale); 836 gfx::ScaleToFlooredPoint(*delta, inverse_scale);
833 if (original_delta != inverse_scaled_point) 837 if (original_delta != inverse_scaled_point)
834 return false; 838 return false;
835 } 839 }
836 840
837 return true; 841 return true;
838 } 842 }
839 843
840 } // namespace content 844 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_graphics_2d_host.h ('k') | content/renderer/pepper/pepper_plugin_instance_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698