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