| 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 13 matching lines...) Expand all Loading... |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "platform/graphics/GradientGeneratedImage.h" | 26 #include "platform/graphics/GradientGeneratedImage.h" |
| 27 | 27 |
| 28 #include "platform/geometry/FloatRect.h" | 28 #include "platform/geometry/FloatRect.h" |
| 29 #include "platform/geometry/IntSize.h" | 29 #include "platform/geometry/IntSize.h" |
| 30 #include "platform/graphics/GraphicsContext.h" | 30 #include "platform/graphics/GraphicsContext.h" |
| 31 | 31 |
| 32 namespace blink { | 32 namespace blink { |
| 33 | 33 |
| 34 void GradientGeneratedImage::draw(SkCanvas* canvas, | 34 void GradientGeneratedImage::draw(PaintCanvas* canvas, |
| 35 const SkPaint& paint, | 35 const PaintFlags& paint, |
| 36 const FloatRect& destRect, | 36 const FloatRect& destRect, |
| 37 const FloatRect& srcRect, | 37 const FloatRect& srcRect, |
| 38 RespectImageOrientationEnum, | 38 RespectImageOrientationEnum, |
| 39 ImageClampingMode, | 39 ImageClampingMode, |
| 40 const ColorBehavior& colorBehavior) { | 40 const ColorBehavior& colorBehavior) { |
| 41 // TODO(ccameron): This function should not ignore |colorBehavior|. | 41 // TODO(ccameron): This function should not ignore |colorBehavior|. |
| 42 // https://crbug.com/672306 | 42 // https://crbug.com/672306 |
| 43 SkRect visibleSrcRect = srcRect; | 43 SkRect visibleSrcRect = srcRect; |
| 44 if (!visibleSrcRect.intersect( | 44 if (!visibleSrcRect.intersect( |
| 45 SkRect::MakeIWH(m_size.width(), m_size.height()))) | 45 SkRect::MakeIWH(m_size.width(), m_size.height()))) |
| 46 return; | 46 return; |
| 47 | 47 |
| 48 const SkMatrix transform = | 48 const SkMatrix transform = |
| 49 SkMatrix::MakeRectToRect(srcRect, destRect, SkMatrix::kFill_ScaleToFit); | 49 SkMatrix::MakeRectToRect(srcRect, destRect, SkMatrix::kFill_ScaleToFit); |
| 50 SkRect visibleDestRect; | 50 SkRect visibleDestRect; |
| 51 transform.mapRect(&visibleDestRect, visibleSrcRect); | 51 transform.mapRect(&visibleDestRect, visibleSrcRect); |
| 52 | 52 |
| 53 SkPaint gradientPaint(paint); | 53 PaintFlags gradientPaint(paint); |
| 54 m_gradient->applyToPaint(gradientPaint, transform); | 54 m_gradient->applyToPaint(gradientPaint, transform); |
| 55 canvas->drawRect(visibleDestRect, gradientPaint); | 55 canvas->drawRect(visibleDestRect, gradientPaint); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void GradientGeneratedImage::drawTile(GraphicsContext& context, | 58 void GradientGeneratedImage::drawTile(GraphicsContext& context, |
| 59 const FloatRect& srcRect) { | 59 const FloatRect& srcRect) { |
| 60 // TODO(ccameron): This function should not ignore |context|'s color behavior. | 60 // TODO(ccameron): This function should not ignore |context|'s color behavior. |
| 61 // https://crbug.com/672306 | 61 // https://crbug.com/672306 |
| 62 SkPaint gradientPaint(context.fillPaint()); | 62 PaintFlags gradientPaint(context.fillPaint()); |
| 63 m_gradient->applyToPaint(gradientPaint, SkMatrix::I()); | 63 m_gradient->applyToPaint(gradientPaint, SkMatrix::I()); |
| 64 | 64 |
| 65 context.drawRect(srcRect, gradientPaint); | 65 context.drawRect(srcRect, gradientPaint); |
| 66 } | 66 } |
| 67 | 67 |
| 68 bool GradientGeneratedImage::applyShader(SkPaint& paint, | 68 bool GradientGeneratedImage::applyShader(PaintFlags& paint, |
| 69 const SkMatrix& localMatrix, | 69 const SkMatrix& localMatrix, |
| 70 const ColorBehavior& colorBehavior) { | 70 const ColorBehavior& colorBehavior) { |
| 71 // TODO(ccameron): This function should not ignore |colorBehavior|. | 71 // TODO(ccameron): This function should not ignore |colorBehavior|. |
| 72 // https://crbug.com/672306 | 72 // https://crbug.com/672306 |
| 73 DCHECK(m_gradient); | 73 DCHECK(m_gradient); |
| 74 m_gradient->applyToPaint(paint, localMatrix); | 74 m_gradient->applyToPaint(paint, localMatrix); |
| 75 | 75 |
| 76 return true; | 76 return true; |
| 77 } | 77 } |
| 78 | 78 |
| 79 } // namespace blink | 79 } // namespace blink |
| OLD | NEW |