| 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/skbitmap_operations.h" | 5 #include "ui/gfx/skbitmap_operations.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 canvas.restore(); | 750 canvas.restore(); |
| 751 } | 751 } |
| 752 | 752 |
| 753 canvas.drawBitmap(bitmap, SkIntToScalar(0), SkIntToScalar(0)); | 753 canvas.drawBitmap(bitmap, SkIntToScalar(0), SkIntToScalar(0)); |
| 754 return image_with_shadow; | 754 return image_with_shadow; |
| 755 } | 755 } |
| 756 | 756 |
| 757 // static | 757 // static |
| 758 SkBitmap SkBitmapOperations::Rotate(const SkBitmap& source, | 758 SkBitmap SkBitmapOperations::Rotate(const SkBitmap& source, |
| 759 RotationAmount rotation) { | 759 RotationAmount rotation) { |
| 760 // SkCanvas::drawBitmap() fails silently with unpremultiplied SkBitmap. |
| 761 DCHECK(source.info().alphaType() != kUnpremul_SkAlphaType); |
| 762 |
| 760 SkBitmap result; | 763 SkBitmap result; |
| 761 SkScalar angle = SkFloatToScalar(0.0f); | 764 SkScalar angle = SkFloatToScalar(0.0f); |
| 762 | 765 |
| 763 switch (rotation) { | 766 switch (rotation) { |
| 764 case ROTATION_90_CW: | 767 case ROTATION_90_CW: |
| 765 angle = SkFloatToScalar(90.0f); | 768 angle = SkFloatToScalar(90.0f); |
| 766 result.allocN32Pixels(source.height(), source.width()); | 769 result.allocN32Pixels(source.height(), source.width()); |
| 767 break; | 770 break; |
| 768 case ROTATION_180_CW: | 771 case ROTATION_180_CW: |
| 769 angle = SkFloatToScalar(180.0f); | 772 angle = SkFloatToScalar(180.0f); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 781 canvas.translate(SkFloatToScalar(result.width() * 0.5f), | 784 canvas.translate(SkFloatToScalar(result.width() * 0.5f), |
| 782 SkFloatToScalar(result.height() * 0.5f)); | 785 SkFloatToScalar(result.height() * 0.5f)); |
| 783 canvas.rotate(angle); | 786 canvas.rotate(angle); |
| 784 canvas.translate(-SkFloatToScalar(source.width() * 0.5f), | 787 canvas.translate(-SkFloatToScalar(source.width() * 0.5f), |
| 785 -SkFloatToScalar(source.height() * 0.5f)); | 788 -SkFloatToScalar(source.height() * 0.5f)); |
| 786 canvas.drawBitmap(source, 0, 0); | 789 canvas.drawBitmap(source, 0, 0); |
| 787 canvas.flush(); | 790 canvas.flush(); |
| 788 | 791 |
| 789 return result; | 792 return result; |
| 790 } | 793 } |
| OLD | NEW |