| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008, 2009, 2010, 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009, 2010, 2012 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 { | 35 { |
| 36 SkRect visibleRect = srcRect; | 36 SkRect visibleRect = srcRect; |
| 37 if (!visibleRect.intersect(SkRect::MakeIWH(m_size.width(), m_size.height()))
) | 37 if (!visibleRect.intersect(SkRect::MakeIWH(m_size.width(), m_size.height()))
) |
| 38 return; | 38 return; |
| 39 | 39 |
| 40 SkMatrix transform = SkMatrix::MakeRectToRect(srcRect, destRect, SkMatrix::k
Fill_ScaleToFit); | 40 SkMatrix transform = SkMatrix::MakeRectToRect(srcRect, destRect, SkMatrix::k
Fill_ScaleToFit); |
| 41 SkAutoCanvasRestore autoRestore(canvas, !transform.isIdentity()); | 41 SkAutoCanvasRestore autoRestore(canvas, !transform.isIdentity()); |
| 42 canvas->concat(transform); | 42 canvas->concat(transform); |
| 43 | 43 |
| 44 SkPaint gradientPaint(paint); | 44 SkPaint gradientPaint(paint); |
| 45 m_gradient->applyToPaint(gradientPaint); | 45 // TODO(fmalita): use the shader matrix instead of changing global canvas st
ate. |
| 46 m_gradient->applyToPaint(gradientPaint, SkMatrix::I()); |
| 46 | 47 |
| 47 canvas->drawRect(visibleRect, gradientPaint); | 48 canvas->drawRect(visibleRect, gradientPaint); |
| 48 } | 49 } |
| 49 | 50 |
| 50 void GradientGeneratedImage::drawTile(GraphicsContext& context, const FloatRect&
srcRect) | 51 void GradientGeneratedImage::drawTile(GraphicsContext& context, const FloatRect&
srcRect) |
| 51 { | 52 { |
| 52 SkPaint gradientPaint(context.fillPaint()); | 53 SkPaint gradientPaint(context.fillPaint()); |
| 53 m_gradient->applyToPaint(gradientPaint); | 54 m_gradient->applyToPaint(gradientPaint, SkMatrix::I()); |
| 54 | 55 |
| 55 context.drawRect(srcRect, gradientPaint); | 56 context.drawRect(srcRect, gradientPaint); |
| 56 } | 57 } |
| 57 | 58 |
| 58 bool GradientGeneratedImage::applyShader(SkPaint& paint, const SkMatrix* localMa
trix) | 59 bool GradientGeneratedImage::applyShader(SkPaint& paint, const SkMatrix* localMa
trix) |
| 59 { | 60 { |
| 60 AffineTransform transform; | |
| 61 if (localMatrix) { | |
| 62 transform.setMatrix( | |
| 63 localMatrix->getScaleX(), localMatrix->getSkewY(), | |
| 64 localMatrix->getSkewX(), localMatrix->getScaleY(), | |
| 65 localMatrix->getTranslateX(), localMatrix->getTranslateY()); | |
| 66 } | |
| 67 | |
| 68 DCHECK(m_gradient); | 61 DCHECK(m_gradient); |
| 69 // TODO(fmalita): remove the transform from gradient/pattern state, and pass
the matrix to | 62 // TODO(fmalita): pass a const SkMatrix& to applyShader. |
| 70 // applyToPaint if needed. | 63 m_gradient->applyToPaint(paint, localMatrix ? *localMatrix : SkMatrix::I()); |
| 71 const AffineTransform previousTransform = m_gradient->gradientSpaceTransform
(); | |
| 72 m_gradient->setGradientSpaceTransform(transform); | |
| 73 m_gradient->applyToPaint(paint); | |
| 74 m_gradient->setGradientSpaceTransform(previousTransform); | |
| 75 | 64 |
| 76 return true; | 65 return true; |
| 77 } | 66 } |
| 78 | 67 |
| 79 } // namespace blink | 68 } // namespace blink |
| OLD | NEW |