[email protected] | 5a9bb95 | 2010-02-11 23:46:04 | [diff] [blame] | 1 | // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
[email protected] | 05b7f99 | 2008-12-03 21:28:33 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | 18539ee | 2010-09-16 21:39:29 | [diff] [blame] | 5 | #ifndef GFX_SKIA_UTIL_H_ |
| 6 | #define GFX_SKIA_UTIL_H_ |
[email protected] | 32b76ef | 2010-07-26 23:08:24 | [diff] [blame] | 7 | #pragma once |
[email protected] | 05b7f99 | 2008-12-03 21:28:33 | [diff] [blame] | 8 | |
[email protected] | c43c668 | 2009-05-19 14:51:44 | [diff] [blame] | 9 | #include "third_party/skia/include/core/SkColor.h" |
[email protected] | 5a9bb95 | 2010-02-11 23:46:04 | [diff] [blame] | 10 | #include "third_party/skia/include/core/SkRect.h" |
[email protected] | cab34d6a | 2009-09-24 01:14:52 | [diff] [blame] | 11 | |
[email protected] | 18539ee | 2010-09-16 21:39:29 | [diff] [blame] | 12 | class SkBitmap; |
[email protected] | cab34d6a | 2009-09-24 01:14:52 | [diff] [blame] | 13 | class SkShader; |
[email protected] | 05b7f99 | 2008-12-03 21:28:33 | [diff] [blame] | 14 | |
[email protected] | 5a9bb95 | 2010-02-11 23:46:04 | [diff] [blame] | 15 | namespace gfx { |
| 16 | |
| 17 | class Rect; |
| 18 | |
| 19 | // Convert between Skia and gfx rect types. |
| 20 | SkRect RectToSkRect(const gfx::Rect& rect); |
| 21 | gfx::Rect SkRectToRect(const SkRect& rect); |
[email protected] | 05b7f99 | 2008-12-03 21:28:33 | [diff] [blame] | 22 | |
| 23 | // Creates a vertical gradient shader. The caller owns the shader. |
| 24 | // Example usage to avoid leaks: |
[email protected] | 3d805c3 | 2010-09-24 17:22:26 | [diff] [blame] | 25 | // SkSafeUnref(paint.setShader(gfx::CreateGradientShader(0, 10, red, blue))); |
[email protected] | 05b7f99 | 2008-12-03 21:28:33 | [diff] [blame] | 26 | // |
[email protected] | 3d805c3 | 2010-09-24 17:22:26 | [diff] [blame] | 27 | // (The old shader in the paint, if any, needs to be freed, and SkSafeUnref will |
[email protected] | 05b7f99 | 2008-12-03 21:28:33 | [diff] [blame] | 28 | // handle the NULL case.) |
| 29 | SkShader* CreateGradientShader(int start_point, |
| 30 | int end_point, |
| 31 | SkColor start_color, |
| 32 | SkColor end_color); |
[email protected] | 05b7f99 | 2008-12-03 21:28:33 | [diff] [blame] | 33 | |
[email protected] | 18539ee | 2010-09-16 21:39:29 | [diff] [blame] | 34 | // Returns true if the two bitmaps contain the same pixels. |
| 35 | bool BitmapsAreEqual(const SkBitmap& bitmap1, const SkBitmap& bitmap2); |
| 36 | |
[email protected] | 5a9bb95 | 2010-02-11 23:46:04 | [diff] [blame] | 37 | } // namespace gfx; |
[email protected] | 05b7f99 | 2008-12-03 21:28:33 | [diff] [blame] | 38 | |
[email protected] | 18539ee | 2010-09-16 21:39:29 | [diff] [blame] | 39 | #endif // GFX_SKIA_UTIL_H_ |