| OLD | NEW |
| 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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 | 257 |
| 258 void Image::drawPattern(GraphicsContext& context, | 258 void Image::drawPattern(GraphicsContext& context, |
| 259 const FloatRect& floatSrcRect, | 259 const FloatRect& floatSrcRect, |
| 260 const FloatSize& scale, | 260 const FloatSize& scale, |
| 261 const FloatPoint& phase, | 261 const FloatPoint& phase, |
| 262 SkBlendMode compositeOp, | 262 SkBlendMode compositeOp, |
| 263 const FloatRect& destRect, | 263 const FloatRect& destRect, |
| 264 const FloatSize& repeatSpacing) { | 264 const FloatSize& repeatSpacing) { |
| 265 TRACE_EVENT0("skia", "Image::drawPattern"); | 265 TRACE_EVENT0("skia", "Image::drawPattern"); |
| 266 | 266 |
| 267 sk_sp<SkImage> image = | 267 sk_sp<SkImage> image = imageForCurrentFrame(); |
| 268 imageForCurrentFrame(ColorBehavior::transformToGlobalTarget()); | |
| 269 if (!image) | 268 if (!image) |
| 270 return; | 269 return; |
| 271 | 270 |
| 272 FloatRect normSrcRect = floatSrcRect; | 271 FloatRect normSrcRect = floatSrcRect; |
| 273 | 272 |
| 274 normSrcRect.intersect(FloatRect(0, 0, image->width(), image->height())); | 273 normSrcRect.intersect(FloatRect(0, 0, image->width(), image->height())); |
| 275 if (destRect.isEmpty() || normSrcRect.isEmpty()) | 274 if (destRect.isEmpty() || normSrcRect.isEmpty()) |
| 276 return; // nothing to draw | 275 return; // nothing to draw |
| 277 | 276 |
| 278 SkMatrix localMatrix; | 277 SkMatrix localMatrix; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 | 328 |
| 330 PassRefPtr<Image> Image::imageForDefaultFrame() { | 329 PassRefPtr<Image> Image::imageForDefaultFrame() { |
| 331 RefPtr<Image> image(this); | 330 RefPtr<Image> image(this); |
| 332 | 331 |
| 333 return image.release(); | 332 return image.release(); |
| 334 } | 333 } |
| 335 | 334 |
| 336 bool Image::applyShader(PaintFlags& flags, const SkMatrix& localMatrix) { | 335 bool Image::applyShader(PaintFlags& flags, const SkMatrix& localMatrix) { |
| 337 // Default shader impl: attempt to build a shader based on the current frame | 336 // Default shader impl: attempt to build a shader based on the current frame |
| 338 // SkImage. | 337 // SkImage. |
| 339 sk_sp<SkImage> image = | 338 sk_sp<SkImage> image = imageForCurrentFrame(); |
| 340 imageForCurrentFrame(ColorBehavior::transformToGlobalTarget()); | |
| 341 if (!image) | 339 if (!image) |
| 342 return false; | 340 return false; |
| 343 | 341 |
| 344 flags.setShader(image->makeShader(SkShader::kRepeat_TileMode, | 342 flags.setShader(image->makeShader(SkShader::kRepeat_TileMode, |
| 345 SkShader::kRepeat_TileMode, &localMatrix)); | 343 SkShader::kRepeat_TileMode, &localMatrix)); |
| 346 if (!flags.getShader()) | 344 if (!flags.getShader()) |
| 347 return false; | 345 return false; |
| 348 | 346 |
| 349 // Animation is normally refreshed in draw() impls, which we don't call when | 347 // Animation is normally refreshed in draw() impls, which we don't call when |
| 350 // painting via shaders. | 348 // painting via shaders. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 380 FloatRect subset = dest; | 378 FloatRect subset = dest; |
| 381 subset.setX((dest.x() - tile.x()) / scale.width()); | 379 subset.setX((dest.x() - tile.x()) / scale.width()); |
| 382 subset.setY((dest.y() - tile.y()) / scale.height()); | 380 subset.setY((dest.y() - tile.y()) / scale.height()); |
| 383 subset.setWidth(dest.width() / scale.width()); | 381 subset.setWidth(dest.width() / scale.width()); |
| 384 subset.setHeight(dest.height() / scale.height()); | 382 subset.setHeight(dest.height() / scale.height()); |
| 385 | 383 |
| 386 return subset; | 384 return subset; |
| 387 } | 385 } |
| 388 | 386 |
| 389 } // namespace blink | 387 } // namespace blink |
| OLD | NEW |