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

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

Issue 2340683002: Advance image animations when drawing as shaders (Closed)
Patch Set: refresh in applyShader() Created 4 years, 3 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
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/backgrounds/animated-gif-as-background-rounded-expected.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 bool Image::applyShader(SkPaint& paint, const SkMatrix& localMatrix) 266 bool Image::applyShader(SkPaint& paint, const SkMatrix& localMatrix)
267 { 267 {
268 // Default shader impl: attempt to build a shader based on the current frame SkImage. 268 // Default shader impl: attempt to build a shader based on the current frame SkImage.
269 sk_sp<SkImage> image = imageForCurrentFrame(); 269 sk_sp<SkImage> image = imageForCurrentFrame();
270 if (!image) 270 if (!image)
271 return false; 271 return false;
272 272
273 paint.setShader( 273 paint.setShader(
274 image->makeShader(SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode , &localMatrix)); 274 image->makeShader(SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode , &localMatrix));
275 275
276 // Animation is normally refreshed in draw() impls, which we don't call when painting via shaders.
277 startAnimation();
278
276 return true; 279 return true;
277 } 280 }
278 281
279 FloatRect Image::computeTileContaining(const FloatPoint& point, 282 FloatRect Image::computeTileContaining(const FloatPoint& point,
280 const FloatSize& tileSize, const FloatPoint& tilePhase, const FloatSize& til eSpacing) 283 const FloatSize& tileSize, const FloatPoint& tilePhase, const FloatSize& til eSpacing)
281 { 284 {
282 const FloatSize actualTileSize(tileSize + tileSpacing); 285 const FloatSize actualTileSize(tileSize + tileSpacing);
283 return FloatRect( 286 return FloatRect(
284 FloatPoint( 287 FloatPoint(
285 point.x() + fmodf(fmodf(-tilePhase.x(), actualTileSize.width()) - ac tualTileSize.width(), actualTileSize.width()), 288 point.x() + fmodf(fmodf(-tilePhase.x(), actualTileSize.width()) - ac tualTileSize.width(), actualTileSize.width()),
(...skipping 12 matching lines...) Expand all
298 FloatRect subset = dest; 301 FloatRect subset = dest;
299 subset.setX((dest.x() - tile.x()) / scale.width()); 302 subset.setX((dest.x() - tile.x()) / scale.width());
300 subset.setY((dest.y() - tile.y()) / scale.height()); 303 subset.setY((dest.y() - tile.y()) / scale.height());
301 subset.setWidth(dest.width() / scale.width()); 304 subset.setWidth(dest.width() / scale.width());
302 subset.setHeight(dest.height() / scale.height()); 305 subset.setHeight(dest.height() / scale.height());
303 306
304 return subset; 307 return subset;
305 } 308 }
306 309
307 } // namespace blink 310 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/backgrounds/animated-gif-as-background-rounded-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698