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

Side by Side Diff: webkit/plugins/ppapi/ppb_graphics_2d_impl.cc

Issue 11110004: Make gfx::Rect class operations consistently mutate the class they are called on. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: cc/ fixes Created 8 years, 2 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 "webkit/plugins/ppapi/ppb_graphics_2d_impl.h" 5 #include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h"
6 6
7 #include <iterator> 7 #include <iterator>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 &scroll_delta : NULL)) { 369 &scroll_delta : NULL)) {
370 // Conversion requires falling back to InvalidateRect. 370 // Conversion requires falling back to InvalidateRect.
371 operation.type = QueuedOperation::PAINT; 371 operation.type = QueuedOperation::PAINT;
372 } 372 }
373 373
374 gfx::Rect clip = PP_ToGfxRect(bound_instance_->view_data().clip_rect); 374 gfx::Rect clip = PP_ToGfxRect(bound_instance_->view_data().clip_rect);
375 is_plugin_visible = !clip.IsEmpty(); 375 is_plugin_visible = !clip.IsEmpty();
376 376
377 // Set |no_update_visible| to false if the change overlaps the visible 377 // Set |no_update_visible| to false if the change overlaps the visible
378 // area. 378 // area.
379 gfx::Rect visible_changed_rect = clip.Intersect(op_rect); 379 gfx::Rect visible_changed_rect = clip;
380 visible_changed_rect.Intersect(op_rect);
380 if (!visible_changed_rect.IsEmpty()) 381 if (!visible_changed_rect.IsEmpty())
381 no_update_visible = false; 382 no_update_visible = false;
382 383
383 // Notify the plugin of the entire change (op_rect), even if it is 384 // Notify the plugin of the entire change (op_rect), even if it is
384 // partially or completely off-screen. 385 // partially or completely off-screen.
385 if (operation.type == QueuedOperation::SCROLL) { 386 if (operation.type == QueuedOperation::SCROLL) {
386 bound_instance_->ScrollRect(scroll_delta.x(), scroll_delta.y(), 387 bound_instance_->ScrollRect(scroll_delta.x(), scroll_delta.y(),
387 op_rect); 388 op_rect);
388 } else { 389 } else {
389 bound_instance_->InvalidateRect(op_rect); 390 bound_instance_->InvalidateRect(op_rect);
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 554
554 // TODO(jhorwich) Figure out if this code is even active anymore, and if so 555 // TODO(jhorwich) Figure out if this code is even active anymore, and if so
555 // how to properly handle scaling. 556 // how to properly handle scaling.
556 DCHECK_EQ(1.0f, scale_); 557 DCHECK_EQ(1.0f, scale_);
557 558
558 // TODO(brettw) bug 56673: do a direct memcpy instead of going through CG 559 // TODO(brettw) bug 56673: do a direct memcpy instead of going through CG
559 // if the is_always_opaque_ flag is set. Must ensure bitmap is still clipped. 560 // if the is_always_opaque_ flag is set. Must ensure bitmap is still clipped.
560 561
561 CGContextDrawImage(canvas, bitmap_rect, image); 562 CGContextDrawImage(canvas, bitmap_rect, image);
562 #else 563 #else
563 gfx::Rect invalidate_rect = plugin_rect.Intersect(paint_rect); 564 gfx::Rect invalidate_rect = plugin_rect;
565 invalidate_rect.Intersect(paint_rect);
564 SkRect sk_invalidate_rect = gfx::RectToSkRect(invalidate_rect); 566 SkRect sk_invalidate_rect = gfx::RectToSkRect(invalidate_rect);
565 SkAutoCanvasRestore auto_restore(canvas, true); 567 SkAutoCanvasRestore auto_restore(canvas, true);
566 canvas->clipRect(sk_invalidate_rect); 568 canvas->clipRect(sk_invalidate_rect);
567 gfx::Size pixel_image_size(image_data_->width(), image_data_->height()); 569 gfx::Size pixel_image_size(image_data_->width(), image_data_->height());
568 gfx::Size image_size = gfx::ToFlooredSize(pixel_image_size.Scale(scale_)); 570 gfx::Size image_size = gfx::ToFlooredSize(pixel_image_size.Scale(scale_));
569 571
570 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this); 572 PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this);
571 if (!plugin_instance) 573 if (!plugin_instance)
572 return; 574 return;
573 if (plugin_instance->IsFullPagePlugin()) { 575 if (plugin_instance->IsFullPagePlugin()) {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 bool PPB_Graphics2D_Impl::ConvertToLogicalPixels(float scale, 642 bool PPB_Graphics2D_Impl::ConvertToLogicalPixels(float scale,
641 gfx::Rect* op_rect, 643 gfx::Rect* op_rect,
642 gfx::Point* delta) { 644 gfx::Point* delta) {
643 if (scale == 1.0f || scale <= 0.0f) 645 if (scale == 1.0f || scale <= 0.0f)
644 return true; 646 return true;
645 647
646 gfx::Rect original_rect = *op_rect; 648 gfx::Rect original_rect = *op_rect;
647 // Take the enclosing rectangle after scaling so a rectangle scaled down then 649 // Take the enclosing rectangle after scaling so a rectangle scaled down then
648 // scaled back up by the inverse scale would fully contain the entire area 650 // scaled back up by the inverse scale would fully contain the entire area
649 // affected by the original rectangle. 651 // affected by the original rectangle.
650 *op_rect = gfx::ToEnclosingRect(op_rect->Scale(scale)); 652 gfx::RectF scaled_rect = *op_rect;
653 scaled_rect.Scale(scale);
654 *op_rect = gfx::ToEnclosingRect(scaled_rect);
651 if (delta) { 655 if (delta) {
652 gfx::Point original_delta = *delta; 656 gfx::Point original_delta = *delta;
653 float inverse_scale = 1.0f / scale; 657 float inverse_scale = 1.0f / scale;
654 *delta = gfx::ToFlooredPoint(delta->Scale(scale)); 658 *delta = gfx::ToFlooredPoint(delta->Scale(scale));
655 if (original_rect != gfx::ToEnclosingRect(op_rect->Scale(inverse_scale)) || 659
660 gfx::RectF inverse_scaled_rect = *op_rect;
661 inverse_scaled_rect.Scale(inverse_scale);
662 if (original_rect != gfx::ToEnclosingRect(inverse_scaled_rect) ||
656 original_delta != gfx::ToFlooredPoint(delta->Scale(inverse_scale))) { 663 original_delta != gfx::ToFlooredPoint(delta->Scale(inverse_scale))) {
657 return false; 664 return false;
658 } 665 }
659 } 666 }
660 667
661 return true; 668 return true;
662 } 669 }
663 670
664 void PPB_Graphics2D_Impl::ExecutePaintImageData(PPB_ImageData_Impl* image, 671 void PPB_Graphics2D_Impl::ExecutePaintImageData(PPB_ImageData_Impl* image,
665 int x, int y, 672 int x, int y,
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 } 762 }
756 763
757 bool PPB_Graphics2D_Impl::HasPendingFlush() const { 764 bool PPB_Graphics2D_Impl::HasPendingFlush() const {
758 return !unpainted_flush_callback_.is_null() || 765 return !unpainted_flush_callback_.is_null() ||
759 !painted_flush_callback_.is_null() || 766 !painted_flush_callback_.is_null() ||
760 offscreen_flush_pending_; 767 offscreen_flush_pending_;
761 } 768 }
762 769
763 } // namespace ppapi 770 } // namespace ppapi
764 } // namespace webkit 771 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/ppapi_plugin_instance.cc ('k') | webkit/plugins/ppapi/ppb_scrollbar_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698