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

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

Issue 9500001: ui/gfx: Simplify RectToSkRect() implementation by using iset() function. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/skia_util.h" 5 #include "ui/gfx/skia_util.h"
6 6
7 #include "base/i18n/char_iterator.h" 7 #include "base/i18n/char_iterator.h"
8 #include "third_party/skia/include/core/SkBitmap.h" 8 #include "third_party/skia/include/core/SkBitmap.h"
9 #include "third_party/skia/include/core/SkColorPriv.h" 9 #include "third_party/skia/include/core/SkColorPriv.h"
10 #include "third_party/skia/include/core/SkShader.h" 10 #include "third_party/skia/include/core/SkShader.h"
11 #include "third_party/skia/include/effects/SkGradientShader.h" 11 #include "third_party/skia/include/effects/SkGradientShader.h"
12 #include "ui/gfx/rect.h" 12 #include "ui/gfx/rect.h"
13 13
14 namespace gfx { 14 namespace gfx {
15 15
16 SkRect RectToSkRect(const gfx::Rect& rect) { 16 SkRect RectToSkRect(const gfx::Rect& rect) {
17 SkRect r; 17 SkRect r;
18 r.set(SkIntToScalar(rect.x()), SkIntToScalar(rect.y()), 18 r.iset(rect.x(), rect.y(), rect.right(), rect.bottom());
19 SkIntToScalar(rect.right()), SkIntToScalar(rect.bottom()));
20 return r; 19 return r;
21 } 20 }
22 21
23 SkIRect RectToSkIRect(const gfx::Rect& rect) { 22 SkIRect RectToSkIRect(const gfx::Rect& rect) {
24 SkIRect r = { rect.x(), rect.y(), rect.right(), rect.bottom() }; 23 SkIRect r = { rect.x(), rect.y(), rect.right(), rect.bottom() };
25 return r; 24 return r;
26 } 25 }
27 26
28 gfx::Rect SkRectToRect(const SkRect& rect) { 27 gfx::Rect SkRectToRect(const SkRect& rect) {
29 return gfx::Rect(static_cast<int>(rect.fLeft), 28 return gfx::Rect(static_cast<int>(rect.left()),
30 static_cast<int>(rect.fTop), 29 static_cast<int>(rect.top()),
31 static_cast<int>(rect.width()), 30 static_cast<int>(rect.width()),
32 static_cast<int>(rect.height())); 31 static_cast<int>(rect.height()));
33 } 32 }
34 33
35 SkShader* CreateGradientShader(int start_point, 34 SkShader* CreateGradientShader(int start_point,
36 int end_point, 35 int end_point,
37 SkColor start_color, 36 SkColor start_color,
38 SkColor end_color) { 37 SkColor end_color) {
39 SkColor grad_colors[2] = { start_color, end_color}; 38 SkColor grad_colors[2] = { start_color, end_color};
40 SkPoint grad_points[2]; 39 SkPoint grad_points[2];
(...skipping 16 matching lines...) Expand all
57 bitmap1.unlockPixels(); 56 bitmap1.unlockPixels();
58 57
59 bitmap2.lockPixels(); 58 bitmap2.lockPixels();
60 addr2 = bitmap2.getAddr32(0, 0); 59 addr2 = bitmap2.getAddr32(0, 0);
61 size2 = bitmap2.getSize(); 60 size2 = bitmap2.getSize();
62 bitmap2.unlockPixels(); 61 bitmap2.unlockPixels();
63 62
64 return (size1 == size2) && (0 == memcmp(addr1, addr2, bitmap1.getSize())); 63 return (size1 == size2) && (0 == memcmp(addr1, addr2, bitmap1.getSize()));
65 } 64 }
66 65
67 string16 RemoveAcceleratorChar(const string16& s, 66 string16 RemoveAcceleratorChar(const string16& s,
tfarina 2012/02/28 16:31:33 Is there a better place for this function? It does
Peter Kasting 2012/02/28 19:18:22 I have no idea. Don't know who uses it or who add
68 char16 accelerator_char, 67 char16 accelerator_char,
69 int *accelerated_char_pos, 68 int *accelerated_char_pos,
70 int *accelerated_char_span) { 69 int *accelerated_char_span) {
71 bool escaped = false; 70 bool escaped = false;
72 int last_char_pos = -1; 71 int last_char_pos = -1;
73 int last_char_span = 0; 72 int last_char_span = 0;
74 base::i18n::UTF16CharIterator chars(&s); 73 base::i18n::UTF16CharIterator chars(&s);
75 string16 accelerator_removed; 74 string16 accelerator_removed;
76 75
77 accelerator_removed.reserve(s.size()); 76 accelerator_removed.reserve(s.size());
(...skipping 18 matching lines...) Expand all
96 95
97 if (accelerated_char_pos) 96 if (accelerated_char_pos)
98 *accelerated_char_pos = last_char_pos; 97 *accelerated_char_pos = last_char_pos;
99 if (accelerated_char_span) 98 if (accelerated_char_span)
100 *accelerated_char_span = last_char_span; 99 *accelerated_char_span = last_char_span;
101 100
102 return accelerator_removed; 101 return accelerator_removed;
103 } 102 }
104 103
105 } // namespace gfx 104 } // namespace gfx
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698