| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/graphics/PaintGeneratedImage.h" | 5 #include "platform/graphics/PaintGeneratedImage.h" |
| 6 | 6 |
| 7 #include "platform/geometry/FloatRect.h" | 7 #include "platform/geometry/FloatRect.h" |
| 8 #include "platform/graphics/GraphicsContext.h" | 8 #include "platform/graphics/GraphicsContext.h" |
| 9 #include "third_party/skia/include/core/SkPicture.h" | 9 #include "platform/graphics/paint/PaintRecord.h" |
| 10 | 10 |
| 11 namespace blink { | 11 namespace blink { |
| 12 | 12 |
| 13 void PaintGeneratedImage::draw(SkCanvas* canvas, | 13 void PaintGeneratedImage::draw(PaintCanvas* canvas, |
| 14 const SkPaint& paint, | 14 const PaintFlags& paint, |
| 15 const FloatRect& destRect, | 15 const FloatRect& destRect, |
| 16 const FloatRect& srcRect, | 16 const FloatRect& srcRect, |
| 17 RespectImageOrientationEnum, | 17 RespectImageOrientationEnum, |
| 18 ImageClampingMode, | 18 ImageClampingMode, |
| 19 const ColorBehavior& colorBehavior) { | 19 const ColorBehavior& colorBehavior) { |
| 20 // TODO(ccameron): This function should not ignore |colorBehavior|. | 20 // TODO(ccameron): This function should not ignore |colorBehavior|. |
| 21 // https://crbug.com/672306 | 21 // https://crbug.com/672306 |
| 22 SkAutoCanvasRestore ar(canvas, true); | 22 PaintCanvasAutoRestore ar(canvas, true); |
| 23 canvas->clipRect(destRect); | 23 canvas->clipRect(destRect); |
| 24 canvas->translate(destRect.x(), destRect.y()); | 24 canvas->translate(destRect.x(), destRect.y()); |
| 25 if (destRect.size() != srcRect.size()) | 25 if (destRect.size() != srcRect.size()) |
| 26 canvas->scale(destRect.width() / srcRect.width(), | 26 canvas->scale(destRect.width() / srcRect.width(), |
| 27 destRect.height() / srcRect.height()); | 27 destRect.height() / srcRect.height()); |
| 28 canvas->translate(-srcRect.x(), -srcRect.y()); | 28 canvas->translate(-srcRect.x(), -srcRect.y()); |
| 29 canvas->drawPicture(m_picture.get(), nullptr, &paint); | 29 canvas->drawPicture(m_picture.get(), nullptr, &paint); |
| 30 } | 30 } |
| 31 | 31 |
| 32 void PaintGeneratedImage::drawTile(GraphicsContext& context, | 32 void PaintGeneratedImage::drawTile(GraphicsContext& context, |
| 33 const FloatRect& srcRect) { | 33 const FloatRect& srcRect) { |
| 34 // TODO(ccameron): This function should not ignore |context|'s color behavior. | 34 // TODO(ccameron): This function should not ignore |context|'s color behavior. |
| 35 // https://crbug.com/672306 | 35 // https://crbug.com/672306 |
| 36 context.drawPicture(m_picture.get()); | 36 context.drawPicture(m_picture.get()); |
| 37 } | 37 } |
| 38 | 38 |
| 39 } // namespace blink | 39 } // namespace blink |
| OLD | NEW |