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

Unified Diff: third_party/WebKit/Source/platform/graphics/Image.cpp

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
Index: third_party/WebKit/Source/platform/graphics/Image.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/Image.cpp b/third_party/WebKit/Source/platform/graphics/Image.cpp
index c0fe493df46129c4a1ca11c08c0c329162c1f085..d930750d1e5a688a23af043f0892e03b0f66f83d 100644
--- a/third_party/WebKit/Source/platform/graphics/Image.cpp
+++ b/third_party/WebKit/Source/platform/graphics/Image.cpp
@@ -227,14 +227,15 @@ void Image::DrawTiledBorder(GraphicsContext& ctxt,
namespace {
-sk_sp<PaintShader> CreatePatternShader(const PaintImage& image,
- const SkMatrix& shader_matrix,
- const PaintFlags& paint,
- const FloatSize& spacing,
- SkShader::TileMode tmx,
- SkShader::TileMode tmy) {
- if (spacing.IsZero())
- return MakePaintShaderImage(image.sk_image(), tmx, tmy, &shader_matrix);
+std::unique_ptr<PaintShader> CreatePatternShader(const PaintImage& image,
+ const SkMatrix& shader_matrix,
+ const PaintFlags& paint,
+ const FloatSize& spacing,
+ SkShader::TileMode tmx,
+ SkShader::TileMode tmy) {
+ if (spacing.IsZero()) {
+ return PaintShader::MakeImage(image.sk_image(), tmx, tmy, &shader_matrix);
+ }
// Arbitrary tiling is currently only supported for SkPictureShader, so we use
// that instead of a plain bitmap shader to implement spacing.
@@ -246,8 +247,8 @@ sk_sp<PaintShader> CreatePatternShader(const PaintImage& image,
PaintCanvas* canvas = recorder.beginRecording(tile_rect);
canvas->drawImage(image, 0, 0, &paint);
- return MakePaintShaderRecord(recorder.finishRecordingAsPicture(), tile_rect,
- tmx, tmy, &shader_matrix);
+ return PaintShader::MakePaintRecord(recorder.finishRecordingAsPicture(),
+ tile_rect, tmx, tmy, &shader_matrix);
}
SkShader::TileMode ComputeTileMode(float left,
@@ -327,7 +328,7 @@ void Image::DrawPattern(GraphicsContext& context,
// If the shader could not be instantiated (e.g. non-invertible matrix),
// draw transparent.
// Note: we can't simply bail, because of arbitrary blend mode.
- if (!flags.getShader())
+ if (!flags.HasShader())
flags.setColor(SK_ColorTRANSPARENT);
context.DrawRect(dest_rect, flags);
@@ -359,9 +360,10 @@ bool Image::ApplyShader(PaintFlags& flags, const SkMatrix& local_matrix) {
if (!image)
return false;
- flags.setShader(image->makeShader(SkShader::kRepeat_TileMode,
- SkShader::kRepeat_TileMode, &local_matrix));
- if (!flags.getShader())
+ flags.setShader(
+ PaintShader::MakeImage(std::move(image), SkShader::kRepeat_TileMode,
+ SkShader::kRepeat_TileMode, &local_matrix));
+ if (!flags.HasShader())
return false;
// Animation is normally refreshed in draw() impls, which we don't call when
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/Gradient.cpp ('k') | third_party/WebKit/Source/platform/graphics/ImagePattern.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698