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

Side by Side Diff: gfx/skia_util.cc

Issue 6246027: Move src/gfx/ to src/ui/gfx... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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 | « gfx/skia_util.h ('k') | gfx/skia_utils_gtk.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "gfx/skia_util.h"
6
7 #include "gfx/rect.h"
8 #include "third_party/skia/include/core/SkBitmap.h"
9 #include "third_party/skia/include/core/SkColorPriv.h"
10 #include "third_party/skia/include/core/SkShader.h"
11 #include "third_party/skia/include/effects/SkGradientShader.h"
12
13 namespace gfx {
14
15 SkRect RectToSkRect(const gfx::Rect& rect) {
16 SkRect r;
17 r.set(SkIntToScalar(rect.x()), SkIntToScalar(rect.y()),
18 SkIntToScalar(rect.right()), SkIntToScalar(rect.bottom()));
19 return r;
20 }
21
22 gfx::Rect SkRectToRect(const SkRect& rect) {
23 return gfx::Rect(SkScalarToFixed(rect.fLeft),
24 SkScalarToFixed(rect.fTop),
25 SkScalarToFixed(rect.width()),
26 SkScalarToFixed(rect.height()));
27 }
28
29 SkShader* CreateGradientShader(int start_point,
30 int end_point,
31 SkColor start_color,
32 SkColor end_color) {
33 SkColor grad_colors[2] = { start_color, end_color};
34 SkPoint grad_points[2];
35 grad_points[0].set(SkIntToScalar(0), SkIntToScalar(start_point));
36 grad_points[1].set(SkIntToScalar(0), SkIntToScalar(end_point));
37
38 return SkGradientShader::CreateLinear(
39 grad_points, grad_colors, NULL, 2, SkShader::kRepeat_TileMode);
40 }
41
42 bool BitmapsAreEqual(const SkBitmap& bitmap1, const SkBitmap& bitmap2) {
43 void* addr1 = NULL;
44 void* addr2 = NULL;
45 size_t size1 = 0;
46 size_t size2 = 0;
47
48 bitmap1.lockPixels();
49 addr1 = bitmap1.getAddr32(0, 0);
50 size1 = bitmap1.getSize();
51 bitmap1.unlockPixels();
52
53 bitmap2.lockPixels();
54 addr2 = bitmap2.getAddr32(0, 0);
55 size2 = bitmap2.getSize();
56 bitmap2.unlockPixels();
57
58 return (size1 == size2) && (0 == memcmp(addr1, addr2, bitmap1.getSize()));
59 }
60
61 } // namespace gfx
OLDNEW
« no previous file with comments | « gfx/skia_util.h ('k') | gfx/skia_utils_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698