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

Unified Diff: ui/gfx/skia_util.h

Issue 11418217: Add skia::RefPtr class to wrap ref counted classes from Skia. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Drop TNoRef Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: ui/gfx/skia_util.h
diff --git a/ui/gfx/skia_util.h b/ui/gfx/skia_util.h
index 66824079b3746cb89a9bb69ad6c285248a97cb51..bd9478fced9aa28f379548689ff3208c3ceec9b8 100644
--- a/ui/gfx/skia_util.h
+++ b/ui/gfx/skia_util.h
@@ -8,6 +8,7 @@
#include <string>
#include <vector>
+#include "skia/ext/refptr.h"
#include "third_party/skia/include/core/SkColor.h"
#include "third_party/skia/include/core/SkRect.h"
#include "third_party/skia/include/core/SkShader.h"
@@ -36,33 +37,23 @@ UI_EXPORT RectF SkRectToRectF(const SkRect& rect);
// The shader's local matrix should not be changed after the shader is created.
// TODO(pkotwicz): Allow shader's local matrix to be changed after the shader
// is created.
-// Example usage to avoid leaks:
-// SkSafeUnref(paint.setShader(gfx::CreateImageRepShader(image_rep,
-// tile_mode, matrix)));
//
-// (The old shader in the paint, if any, needs to be freed, and SkSafeUnref will
-// handle the NULL case.)
-UI_EXPORT SkShader* CreateImageRepShader(const gfx::ImageSkiaRep& image_rep,
- SkShader::TileMode tile_mode,
- const SkMatrix& local_matrix);
+UI_EXPORT skia::RefPtr<SkShader> CreateImageRepShader(
+ const gfx::ImageSkiaRep& image_rep,
+ SkShader::TileMode tile_mode,
+ const SkMatrix& local_matrix);
// Creates a vertical gradient shader. The caller owns the shader.
// Example usage to avoid leaks:
-// SkSafeUnref(paint.setShader(gfx::CreateGradientShader(0, 10, red, blue)));
-//
-// (The old shader in the paint, if any, needs to be freed, and SkSafeUnref will
-// handle the NULL case.)
-UI_EXPORT SkShader* CreateGradientShader(int start_point,
- int end_point,
- SkColor start_color,
- SkColor end_color);
+UI_EXPORT skia::RefPtr<SkShader> CreateGradientShader(int start_point,
+ int end_point,
+ SkColor start_color,
+ SkColor end_color);
// Creates a draw looper to generate |shadows|. The caller owns the draw looper.
// NULL is returned if |shadows| is empty since no draw looper is needed in
// this case.
-// Example usage to avoid leaks:
-// SkSafeUnref(paint.setDrawLooper(gfx::CreateShadowDrawLooper(shadows)));
-UI_EXPORT SkDrawLooper* CreateShadowDrawLooper(
+UI_EXPORT skia::RefPtr<SkDrawLooper> CreateShadowDrawLooper(
const std::vector<ShadowValue>& shadows);
// Returns true if the two bitmaps contain the same pixels.

Powered by Google App Engine
This is Rietveld 408576698