summaryrefslogtreecommitdiffstats
path: root/skia
diff options
context:
space:
mode:
authorbrettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-03 21:28:33 +0000
committerbrettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-03 21:28:33 +0000
commit05b7f994c66470750905eabb12acf1643099f9b7 (patch)
treed9411a629dfb1e8dc4885374d5f788bcff47ea86 /skia
parent9ed68c36cad4f5d70a378be96d303710053eed65 (diff)
downloadchromium_src-05b7f994c66470750905eabb12acf1643099f9b7.zip
chromium_src-05b7f994c66470750905eabb12acf1643099f9b7.tar.gz
chromium_src-05b7f994c66470750905eabb12acf1643099f9b7.tar.bz2
Split the cross-platform part of skia_utils_win into skia_utils. Use this new
function when possible. Add a little documentation. This does not change the Mac build, I'll do that in a separate pass, and the function moved is never used on the mac). Review URL: http://codereview.chromium.org/12917 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6312 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia')
-rw-r--r--skia/SConscript1
-rw-r--r--skia/ext/skia_utils.cc25
-rw-r--r--skia/ext/skia_utils.h27
-rw-r--r--skia/ext/skia_utils_win.cc14
-rw-r--r--skia/ext/skia_utils_win.h7
-rw-r--r--skia/skia.vcproj8
6 files changed, 61 insertions, 21 deletions
diff --git a/skia/SConscript b/skia/SConscript
index 5c17f5b..eb1f265 100644
--- a/skia/SConscript
+++ b/skia/SConscript
@@ -82,6 +82,7 @@ input_files = [
'effects/SkUnitMappers.cpp',
'ext/image_operations.cc',
'ext/convolver.cc',
+ 'ext/skia_utils.cc',
'images/SkImageDecoder.cpp',
'images/SkImageRef.cpp',
'images/SkStream.cpp',
diff --git a/skia/ext/skia_utils.cc b/skia/ext/skia_utils.cc
new file mode 100644
index 0000000..b2ea44f
--- /dev/null
+++ b/skia/ext/skia_utils.cc
@@ -0,0 +1,25 @@
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "skia/ext/skia_utils.h"
+
+#include "SkGradientShader.h"
+
+namespace gfx {
+
+SkShader* CreateGradientShader(int start_point,
+ int end_point,
+ SkColor start_color,
+ SkColor end_color) {
+ SkColor grad_colors[2] = { start_color, end_color};
+ SkPoint grad_points[2];
+ grad_points[0].set(SkIntToScalar(0), SkIntToScalar(start_point));
+ grad_points[1].set(SkIntToScalar(0), SkIntToScalar(end_point));
+
+ return SkGradientShader::CreateLinear(
+ grad_points, grad_colors, NULL, 2, SkShader::kRepeat_TileMode);
+}
+
+} // namespace gfx
+
diff --git a/skia/ext/skia_utils.h b/skia/ext/skia_utils.h
new file mode 100644
index 0000000..d2ed5db
--- /dev/null
+++ b/skia/ext/skia_utils.h
@@ -0,0 +1,27 @@
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef BASE_GFX_SKIA_UTILS_H_
+#define BASE_GFX_SKIA_UTILS_H_
+
+#include "SkColor.h"
+#include "SkShader.h"
+
+namespace gfx {
+
+// Creates a vertical gradient shader. The caller owns the shader.
+// Example usage to avoid leaks:
+// paint.setShader(gfx::CreateGradientShader(0, 10, red, blue))->safeUnref();
+//
+// (The old shader in the paint, if any, needs to be freed, and safeUnref will
+// handle the NULL case.)
+SkShader* CreateGradientShader(int start_point,
+ int end_point,
+ SkColor start_color,
+ SkColor end_color);
+
+} // namespace gfx
+
+#endif // SKIA_EXT_SKIA_UTILS_H_
+
diff --git a/skia/ext/skia_utils_win.cc b/skia/ext/skia_utils_win.cc
index dcac26f..05f0692 100644
--- a/skia/ext/skia_utils_win.cc
+++ b/skia/ext/skia_utils_win.cc
@@ -35,20 +35,6 @@ SkRect RECTToSkRect(const RECT& rect) {
return sk_rect;
}
-SkShader* CreateGradientShader(int start_point,
- int end_point,
- SkColor start_color,
- SkColor end_color) {
- SkColor grad_colors[2] = { start_color, end_color};
- SkPoint grad_points[2];
- grad_points[0].set(SkIntToScalar(0), SkIntToScalar(start_point));
- grad_points[1].set(SkIntToScalar(0), SkIntToScalar(end_point));
-
- return SkGradientShader::CreateLinear(
- grad_points, grad_colors, NULL, 2, SkShader::kRepeat_TileMode);
-}
-
-
SkColor COLORREFToSkColor(COLORREF color) {
#ifndef _MSC_VER
return SkColorSetRGB(GetRValue(color), GetGValue(color), GetBValue(color));
diff --git a/skia/ext/skia_utils_win.h b/skia/ext/skia_utils_win.h
index 4ad7910..fa94507 100644
--- a/skia/ext/skia_utils_win.h
+++ b/skia/ext/skia_utils_win.h
@@ -6,7 +6,6 @@
#define BASE_GFX_SKIA_UTILS_WIN_H_
#include "SkColor.h"
-#include "SkShader.h"
struct SkIRect;
struct SkPoint;
@@ -38,12 +37,6 @@ inline const RECT& SkIRectToRECT(const SkIRect& rect) {
return reinterpret_cast<const RECT&>(rect);
}
-// Creates a vertical gradient shader. The caller owns the shader.
-SkShader* CreateGradientShader(int start_point,
- int end_point,
- SkColor start_color,
- SkColor end_color);
-
// Converts COLORREFs (0BGR) to the ARGB layout Skia expects.
SkColor COLORREFToSkColor(COLORREF color);
diff --git a/skia/skia.vcproj b/skia/skia.vcproj
index b44b455..bd4c7c3 100644
--- a/skia/skia.vcproj
+++ b/skia/skia.vcproj
@@ -1361,6 +1361,14 @@
>
</File>
<File
+ RelativePath=".\ext\skia_utils.cc"
+ >
+ </File>
+ <File
+ RelativePath=".\ext\skia_utils.h"
+ >
+ </File>
+ <File
RelativePath=".\ext\skia_utils_win.cc"
>
</File>