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/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/SkColorFilter.h" | 9 #include "third_party/skia/include/core/SkColorFilter.h" |
10 #include "third_party/skia/include/core/SkColorPriv.h" | 10 #include "third_party/skia/include/core/SkColorPriv.h" |
11 #include "third_party/skia/include/core/SkUnPreMultiply.h" | 11 #include "third_party/skia/include/core/SkUnPreMultiply.h" |
12 #include "third_party/skia/include/effects/SkBlurMaskFilter.h" | 12 #include "third_party/skia/include/effects/SkBlurMaskFilter.h" |
13 #include "third_party/skia/include/effects/SkGradientShader.h" | 13 #include "third_party/skia/include/effects/SkGradientShader.h" |
14 #include "third_party/skia/include/effects/SkLayerDrawLooper.h" | 14 #include "third_party/skia/include/effects/SkLayerDrawLooper.h" |
15 #include "ui/gfx/image/image_skia_rep.h" | 15 #include "ui/gfx/image/image_skia_rep.h" |
16 #include "ui/gfx/rect.h" | 16 #include "ui/gfx/rect.h" |
17 #include "ui/gfx/shadow_value.h" | 17 #include "ui/gfx/shadow_value.h" |
18 | 18 |
19 namespace gfx { | 19 namespace gfx { |
20 | 20 |
21 SkRect RectToSkRect(const gfx::Rect& rect) { | 21 SkRect RectToSkRect(const Rect& rect) { |
22 SkRect r; | 22 SkRect r; |
23 r.iset(rect.x(), rect.y(), rect.right(), rect.bottom()); | 23 r.iset(rect.x(), rect.y(), rect.right(), rect.bottom()); |
24 return r; | 24 return r; |
25 } | 25 } |
26 | 26 |
27 SkIRect RectToSkIRect(const gfx::Rect& rect) { | 27 SkIRect RectToSkIRect(const Rect& rect) { |
28 return SkIRect::MakeXYWH(rect.x(), rect.y(), rect.width(), rect.height()); | 28 return SkIRect::MakeXYWH(rect.x(), rect.y(), rect.width(), rect.height()); |
29 } | 29 } |
30 | 30 |
31 gfx::Rect SkRectToRect(const SkRect& rect) { | 31 Rect SkRectToRect(const SkRect& rect) { |
32 return gfx::Rect(static_cast<int>(rect.left()), | 32 return Rect(static_cast<int>(rect.left()), |
33 static_cast<int>(rect.top()), | 33 static_cast<int>(rect.top()), |
34 static_cast<int>(rect.width()), | 34 static_cast<int>(rect.width()), |
35 static_cast<int>(rect.height())); | 35 static_cast<int>(rect.height())); |
| 36 } |
| 37 |
| 38 Rect SkIRectToRect(const SkIRect& rect) { |
| 39 return Rect(rect.x(), rect.y(), rect.width(), rect.height()); |
36 } | 40 } |
37 | 41 |
38 SkShader* CreateImageRepShader(const gfx::ImageSkiaRep& image_rep, | 42 SkShader* CreateImageRepShader(const gfx::ImageSkiaRep& image_rep, |
39 SkShader::TileMode tile_mode, | 43 SkShader::TileMode tile_mode, |
40 const SkMatrix& local_matrix) { | 44 const SkMatrix& local_matrix) { |
41 SkShader* shader = SkShader::CreateBitmapShader(image_rep.sk_bitmap(), | 45 SkShader* shader = SkShader::CreateBitmapShader(image_rep.sk_bitmap(), |
42 tile_mode, tile_mode); | 46 tile_mode, tile_mode); |
43 SkScalar scale_x = local_matrix.getScaleX(); | 47 SkScalar scale_x = local_matrix.getScaleX(); |
44 SkScalar scale_y = local_matrix.getScaleY(); | 48 SkScalar scale_y = local_matrix.getScaleY(); |
45 SkScalar bitmap_scale = SkFloatToScalar(image_rep.GetScale()); | 49 SkScalar bitmap_scale = SkFloatToScalar(image_rep.GetScale()); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 } else { | 189 } else { |
186 rgba[i + 0] = SkGetPackedR32(pixel_in); | 190 rgba[i + 0] = SkGetPackedR32(pixel_in); |
187 rgba[i + 1] = SkGetPackedG32(pixel_in); | 191 rgba[i + 1] = SkGetPackedG32(pixel_in); |
188 rgba[i + 2] = SkGetPackedB32(pixel_in); | 192 rgba[i + 2] = SkGetPackedB32(pixel_in); |
189 rgba[i + 3] = alpha; | 193 rgba[i + 3] = alpha; |
190 } | 194 } |
191 } | 195 } |
192 } | 196 } |
193 | 197 |
194 } // namespace gfx | 198 } // namespace gfx |
OLD | NEW |