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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/Image.cpp

Issue 2743363006: Clean up cc/paint interfaces (Closed)
Patch Set: Fix PaintControllerTest v2 Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 2 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
3 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 } else { 215 } else {
216 drawPattern(ctxt, srcRect, tileScaleFactor, patternPhase, op, dstRect, 216 drawPattern(ctxt, srcRect, tileScaleFactor, patternPhase, op, dstRect,
217 spacing); 217 spacing);
218 } 218 }
219 219
220 startAnimation(); 220 startAnimation();
221 } 221 }
222 222
223 namespace { 223 namespace {
224 224
225 sk_sp<PaintShader> createPatternShader(const SkImage* image, 225 sk_sp<PaintShader> createPatternShader(sk_sp<const SkImage> image,
226 const SkMatrix& shaderMatrix, 226 const SkMatrix& shaderMatrix,
227 const PaintFlags& paint, 227 const PaintFlags& paint,
228 const FloatSize& spacing, 228 const FloatSize& spacing,
229 SkShader::TileMode tmx, 229 SkShader::TileMode tmx,
230 SkShader::TileMode tmy) { 230 SkShader::TileMode tmy) {
231 if (spacing.isZero()) 231 if (spacing.isZero())
232 return MakePaintShaderImage(image, tmx, tmy, &shaderMatrix); 232 return MakePaintShaderImage(image, tmx, tmy, &shaderMatrix);
233 233
234 // Arbitrary tiling is currently only supported for SkPictureShader, so we use 234 // Arbitrary tiling is currently only supported for SkPictureShader, so we use
235 // that instead of a plain bitmap shader to implement spacing. 235 // that instead of a plain bitmap shader to implement spacing.
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 const auto tmy = computeTileMode(destRect.y(), destRect.maxY(), adjustedY, 303 const auto tmy = computeTileMode(destRect.y(), destRect.maxY(), adjustedY,
304 adjustedY + tileSize.height()); 304 adjustedY + tileSize.height());
305 305
306 PaintFlags flags = context.fillFlags(); 306 PaintFlags flags = context.fillFlags();
307 flags.setColor(SK_ColorBLACK); 307 flags.setColor(SK_ColorBLACK);
308 flags.setBlendMode(compositeOp); 308 flags.setBlendMode(compositeOp);
309 flags.setFilterQuality( 309 flags.setFilterQuality(
310 context.computeFilterQuality(this, destRect, normSrcRect)); 310 context.computeFilterQuality(this, destRect, normSrcRect));
311 flags.setAntiAlias(context.shouldAntialias()); 311 flags.setAntiAlias(context.shouldAntialias());
312 flags.setShader( 312 flags.setShader(
313 createPatternShader(image.get(), localMatrix, flags, 313 createPatternShader(std::move(image), localMatrix, flags,
314 FloatSize(repeatSpacing.width() / scale.width(), 314 FloatSize(repeatSpacing.width() / scale.width(),
315 repeatSpacing.height() / scale.height()), 315 repeatSpacing.height() / scale.height()),
316 tmx, tmy)); 316 tmx, tmy));
317 // If the shader could not be instantiated (e.g. non-invertible matrix), 317 // If the shader could not be instantiated (e.g. non-invertible matrix),
318 // draw transparent. 318 // draw transparent.
319 // Note: we can't simply bail, because of arbitrary blend mode. 319 // Note: we can't simply bail, because of arbitrary blend mode.
320 if (!flags.getShader()) 320 if (!flags.getShader())
321 flags.setColor(SK_ColorTRANSPARENT); 321 flags.setColor(SK_ColorTRANSPARENT);
322 322
323 context.drawRect(destRect, flags); 323 context.drawRect(destRect, flags);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 FloatRect subset = dest; 378 FloatRect subset = dest;
379 subset.setX((dest.x() - tile.x()) / scale.width()); 379 subset.setX((dest.x() - tile.x()) / scale.width());
380 subset.setY((dest.y() - tile.y()) / scale.height()); 380 subset.setY((dest.y() - tile.y()) / scale.height());
381 subset.setWidth(dest.width() / scale.width()); 381 subset.setWidth(dest.width() / scale.width());
382 subset.setHeight(dest.height() / scale.height()); 382 subset.setHeight(dest.height() / scale.height());
383 383
384 return subset; 384 return subset;
385 } 385 }
386 386
387 } // namespace blink 387 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698