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

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, 7 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 be2a1d1525ceb304ff6628014244171ae1a12fbe..2136793b1b7e6cc697cd9b0db19e26f72e52240e 100644
--- a/third_party/WebKit/Source/platform/graphics/Image.cpp
+++ b/third_party/WebKit/Source/platform/graphics/Image.cpp
@@ -227,14 +227,16 @@ 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 WTF::MakeUnique<PaintShader>(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 +248,8 @@ sk_sp<PaintShader> CreatePatternShader(const PaintImage& image,
PaintCanvas* canvas = recorder.beginRecording(tile_rect);
canvas->drawImage(image, 0, 0, &paint);
- return MakePaintShaderRecord(recorder.finishRecordingAsPicture(), tmx, tmy,
- &shader_matrix, nullptr);
+ return WTF::MakeUnique<PaintShader>(recorder.finishRecordingAsPicture(), tmx,
+ tmy, &shader_matrix, nullptr);
}
SkShader::TileMode ComputeTileMode(float left,
@@ -327,7 +329,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 +361,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(
+ WTF::MakeUnique<PaintShader>(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

Powered by Google App Engine
This is Rietveld 408576698