| 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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 | 248 |
| 249 void Image::drawPattern(GraphicsContext& context, | 249 void Image::drawPattern(GraphicsContext& context, |
| 250 const FloatRect& floatSrcRect, | 250 const FloatRect& floatSrcRect, |
| 251 const FloatSize& scale, | 251 const FloatSize& scale, |
| 252 const FloatPoint& phase, | 252 const FloatPoint& phase, |
| 253 SkBlendMode compositeOp, | 253 SkBlendMode compositeOp, |
| 254 const FloatRect& destRect, | 254 const FloatRect& destRect, |
| 255 const FloatSize& repeatSpacing) { | 255 const FloatSize& repeatSpacing) { |
| 256 TRACE_EVENT0("skia", "Image::drawPattern"); | 256 TRACE_EVENT0("skia", "Image::drawPattern"); |
| 257 | 257 |
| 258 sk_sp<SkImage> image = imageForCurrentFrame(); | 258 sk_sp<SkImage> image = imageForCurrentFrame(context.getColorBehavior()); |
| 259 if (!image) | 259 if (!image) |
| 260 return; | 260 return; |
| 261 | 261 |
| 262 FloatRect normSrcRect = floatSrcRect; | 262 FloatRect normSrcRect = floatSrcRect; |
| 263 | 263 |
| 264 normSrcRect.intersect(FloatRect(0, 0, image->width(), image->height())); | 264 normSrcRect.intersect(FloatRect(0, 0, image->width(), image->height())); |
| 265 if (destRect.isEmpty() || normSrcRect.isEmpty()) | 265 if (destRect.isEmpty() || normSrcRect.isEmpty()) |
| 266 return; // nothing to draw | 266 return; // nothing to draw |
| 267 | 267 |
| 268 SkMatrix localMatrix; | 268 SkMatrix localMatrix; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 PlatformInstrumentation::didDrawLazyPixelRef(imageID); | 304 PlatformInstrumentation::didDrawLazyPixelRef(imageID); |
| 305 } | 305 } |
| 306 | 306 |
| 307 PassRefPtr<Image> Image::imageForDefaultFrame() { | 307 PassRefPtr<Image> Image::imageForDefaultFrame() { |
| 308 RefPtr<Image> image(this); | 308 RefPtr<Image> image(this); |
| 309 | 309 |
| 310 return image.release(); | 310 return image.release(); |
| 311 } | 311 } |
| 312 | 312 |
| 313 bool Image::isTextureBacked() { | 313 bool Image::isTextureBacked() { |
| 314 sk_sp<SkImage> image = imageForCurrentFrame(); | 314 // TODO(ccameron): It should not be necessary to specify color conversion for |
| 315 // this query. |
| 316 sk_sp<SkImage> image = |
| 317 imageForCurrentFrame(ColorBehavior::transformToGlobalTarget()); |
| 315 return image ? image->isTextureBacked() : false; | 318 return image ? image->isTextureBacked() : false; |
| 316 } | 319 } |
| 317 | 320 |
| 318 bool Image::applyShader(SkPaint& paint, const SkMatrix& localMatrix) { | 321 bool Image::applyShader(SkPaint& paint, |
| 322 const SkMatrix& localMatrix, |
| 323 const ColorBehavior& colorBehavior) { |
| 319 // Default shader impl: attempt to build a shader based on the current frame | 324 // Default shader impl: attempt to build a shader based on the current frame |
| 320 // SkImage. | 325 // SkImage. |
| 321 sk_sp<SkImage> image = imageForCurrentFrame(); | 326 sk_sp<SkImage> image = imageForCurrentFrame(colorBehavior); |
| 322 if (!image) | 327 if (!image) |
| 323 return false; | 328 return false; |
| 324 | 329 |
| 325 paint.setShader(image->makeShader(SkShader::kRepeat_TileMode, | 330 paint.setShader(image->makeShader(SkShader::kRepeat_TileMode, |
| 326 SkShader::kRepeat_TileMode, &localMatrix)); | 331 SkShader::kRepeat_TileMode, &localMatrix)); |
| 327 | 332 |
| 328 // Animation is normally refreshed in draw() impls, which we don't call when | 333 // Animation is normally refreshed in draw() impls, which we don't call when |
| 329 // painting via shaders. | 334 // painting via shaders. |
| 330 startAnimation(); | 335 startAnimation(); |
| 331 | 336 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 359 FloatRect subset = dest; | 364 FloatRect subset = dest; |
| 360 subset.setX((dest.x() - tile.x()) / scale.width()); | 365 subset.setX((dest.x() - tile.x()) / scale.width()); |
| 361 subset.setY((dest.y() - tile.y()) / scale.height()); | 366 subset.setY((dest.y() - tile.y()) / scale.height()); |
| 362 subset.setWidth(dest.width() / scale.width()); | 367 subset.setWidth(dest.width() / scale.width()); |
| 363 subset.setHeight(dest.height() / scale.height()); | 368 subset.setHeight(dest.height() / scale.height()); |
| 364 | 369 |
| 365 return subset; | 370 return subset; |
| 366 } | 371 } |
| 367 | 372 |
| 368 } // namespace blink | 373 } // namespace blink |
| OLD | NEW |