| OLD | NEW |
| 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 "ui/gfx/canvas.h" | 5 #include "ui/gfx/canvas.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 TileImageInt(image, 0, 0, x, y, w, h); | 484 TileImageInt(image, 0, 0, x, y, w, h); |
| 485 } | 485 } |
| 486 | 486 |
| 487 void Canvas::TileImageInt(const ImageSkia& image, | 487 void Canvas::TileImageInt(const ImageSkia& image, |
| 488 int src_x, | 488 int src_x, |
| 489 int src_y, | 489 int src_y, |
| 490 int dest_x, | 490 int dest_x, |
| 491 int dest_y, | 491 int dest_y, |
| 492 int w, | 492 int w, |
| 493 int h, | 493 int h, |
| 494 cc::PaintFlags* flags) { | 494 float tile_scale, |
| 495 TileImageInt(image, src_x, src_y, 1.0f, 1.0f, dest_x, dest_y, w, h, flags); | |
| 496 } | |
| 497 | |
| 498 void Canvas::TileImageInt(const ImageSkia& image, | |
| 499 int src_x, | |
| 500 int src_y, | |
| 501 float tile_scale_x, | |
| 502 float tile_scale_y, | |
| 503 int dest_x, | |
| 504 int dest_y, | |
| 505 int w, | |
| 506 int h, | |
| 507 cc::PaintFlags* flags) { | 495 cc::PaintFlags* flags) { |
| 508 SkRect dest_rect = { SkIntToScalar(dest_x), | 496 SkRect dest_rect = { SkIntToScalar(dest_x), |
| 509 SkIntToScalar(dest_y), | 497 SkIntToScalar(dest_y), |
| 510 SkIntToScalar(dest_x + w), | 498 SkIntToScalar(dest_x + w), |
| 511 SkIntToScalar(dest_y + h) }; | 499 SkIntToScalar(dest_y + h) }; |
| 512 if (!IntersectsClipRect(dest_rect)) | 500 if (!IntersectsClipRect(dest_rect)) |
| 513 return; | 501 return; |
| 514 | 502 |
| 515 cc::PaintFlags paint_flags; | 503 cc::PaintFlags paint_flags; |
| 516 if (!flags) | 504 if (!flags) |
| 517 flags = &paint_flags; | 505 flags = &paint_flags; |
| 518 | 506 |
| 519 if (InitPaintFlagsForTiling(image, src_x, src_y, tile_scale_x, tile_scale_y, | 507 if (InitPaintFlagsForTiling(image, src_x, src_y, tile_scale, tile_scale, |
| 520 dest_x, dest_y, flags)) | 508 dest_x, dest_y, flags)) |
| 521 canvas_->drawRect(dest_rect, *flags); | 509 canvas_->drawRect(dest_rect, *flags); |
| 522 } | 510 } |
| 523 | 511 |
| 524 bool Canvas::InitPaintFlagsForTiling(const ImageSkia& image, | 512 bool Canvas::InitPaintFlagsForTiling(const ImageSkia& image, |
| 525 int src_x, | 513 int src_x, |
| 526 int src_y, | 514 int src_y, |
| 527 float tile_scale_x, | 515 float tile_scale_x, |
| 528 float tile_scale_y, | 516 float tile_scale_y, |
| 529 int dest_x, | 517 int dest_x, |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 bitmap_.emplace(); | 614 bitmap_.emplace(); |
| 627 bitmap_->allocPixels(info); | 615 bitmap_->allocPixels(info); |
| 628 // Ensure that the bitmap is zeroed, since the code expects that. | 616 // Ensure that the bitmap is zeroed, since the code expects that. |
| 629 memset(bitmap_->getPixels(), 0, bitmap_->getSafeSize()); | 617 memset(bitmap_->getPixels(), 0, bitmap_->getSafeSize()); |
| 630 | 618 |
| 631 owned_canvas_ = cc::SkiaPaintCanvas(bitmap_.value()); | 619 owned_canvas_ = cc::SkiaPaintCanvas(bitmap_.value()); |
| 632 return &owned_canvas_.value(); | 620 return &owned_canvas_.value(); |
| 633 } | 621 } |
| 634 | 622 |
| 635 } // namespace gfx | 623 } // namespace gfx |
| OLD | NEW |