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

Side by Side Diff: ui/gfx/skbitmap_operations.cc

Issue 1514723003: Fix bug where custom cursors would dissappear when screen was rotated (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change DCHECK to DCHECK_NE Created 5 years 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
« no previous file with comments | « ui/base/cursor/cursor_util.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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
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_NE(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
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 }
OLDNEW
« no previous file with comments | « ui/base/cursor/cursor_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698