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

Unified Diff: ui/gfx/skia_paint_util.cc

Issue 2893083002: cc: Move SkShader construction to a single spot in PaintShader (Closed)
Patch Set: update Created 3 years, 6 months 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
« no previous file with comments | « ui/gfx/skia_paint_util.h ('k') | ui/native_theme/native_theme_base.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/skia_paint_util.cc
diff --git a/ui/gfx/skia_paint_util.cc b/ui/gfx/skia_paint_util.cc
index dcaea71be1e1ea9e55fa1bd5a9c5cb507f5bd41c..6bbe1ca94adc2da6bc9dc14e20fb8a309a92c2d9 100644
--- a/ui/gfx/skia_paint_util.cc
+++ b/ui/gfx/skia_paint_util.cc
@@ -4,6 +4,7 @@
#include "ui/gfx/skia_paint_util.h"
+#include "base/memory/ptr_util.h"
#include "third_party/skia/include/core/SkColorFilter.h"
#include "third_party/skia/include/effects/SkBlurMaskFilter.h"
#include "third_party/skia/include/effects/SkGradientShader.h"
@@ -12,16 +13,17 @@
namespace gfx {
-sk_sp<cc::PaintShader> CreateImageRepShader(const gfx::ImageSkiaRep& image_rep,
- cc::PaintShader::TileMode tile_mode,
- const SkMatrix& local_matrix) {
- return cc::WrapSkShader(CreateImageRepShaderForScale(
- image_rep, tile_mode, local_matrix, image_rep.scale()));
+std::unique_ptr<cc::PaintShader> CreateImageRepShader(
+ const gfx::ImageSkiaRep& image_rep,
+ SkShader::TileMode tile_mode,
+ const SkMatrix& local_matrix) {
+ return CreateImageRepShaderForScale(image_rep, tile_mode, local_matrix,
+ image_rep.scale());
}
-sk_sp<cc::PaintShader> CreateImageRepShaderForScale(
+std::unique_ptr<cc::PaintShader> CreateImageRepShaderForScale(
const gfx::ImageSkiaRep& image_rep,
- cc::PaintShader::TileMode tile_mode,
+ SkShader::TileMode tile_mode,
const SkMatrix& local_matrix,
SkScalar scale) {
// Unscale matrix by |scale| such that the bitmap is drawn at the
@@ -36,21 +38,22 @@ sk_sp<cc::PaintShader> CreateImageRepShaderForScale(
shader_scale.setScaleX(local_matrix.getScaleX() / scale);
shader_scale.setScaleY(local_matrix.getScaleY() / scale);
- return cc::PaintShader::MakeBitmapShader(image_rep.sk_bitmap(), tile_mode,
- tile_mode, &shader_scale);
+ return cc::PaintShader::MakeImage(
+ SkImage::MakeFromBitmap(image_rep.sk_bitmap()), tile_mode, tile_mode,
+ &shader_scale);
}
-sk_sp<cc::PaintShader> CreateGradientShader(int start_point,
- int end_point,
- SkColor start_color,
- SkColor end_color) {
+std::unique_ptr<cc::PaintShader> 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].iset(0, start_point);
grad_points[1].iset(0, end_point);
- return cc::WrapSkShader(SkGradientShader::MakeLinear(
- grad_points, grad_colors, NULL, 2, cc::PaintShader::kClamp_TileMode));
+ return cc::PaintShader::MakeLinearGradient(grad_points, grad_colors, nullptr,
+ 2, SkShader::kClamp_TileMode);
}
// This is copied from
« no previous file with comments | « ui/gfx/skia_paint_util.h ('k') | ui/native_theme/native_theme_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698