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 "third_party/skia/include/core/SkPicture.h" |
10 | 10 |
11 namespace blink { | 11 namespace blink { |
12 | 12 |
13 void PaintGeneratedImage::draw(SkCanvas* canvas, | 13 void PaintGeneratedImage::draw(SkCanvas* canvas, |
14 const SkPaint& paint, | 14 const SkPaint& 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) { |
| 20 // TODO(ccameron): This function should not ignore |colorBehavior|. |
| 21 // https://crbug.com/672306 |
19 SkAutoCanvasRestore ar(canvas, true); | 22 SkAutoCanvasRestore ar(canvas, true); |
20 canvas->clipRect(destRect); | 23 canvas->clipRect(destRect); |
21 canvas->translate(destRect.x(), destRect.y()); | 24 canvas->translate(destRect.x(), destRect.y()); |
22 if (destRect.size() != srcRect.size()) | 25 if (destRect.size() != srcRect.size()) |
23 canvas->scale(destRect.width() / srcRect.width(), | 26 canvas->scale(destRect.width() / srcRect.width(), |
24 destRect.height() / srcRect.height()); | 27 destRect.height() / srcRect.height()); |
25 canvas->translate(-srcRect.x(), -srcRect.y()); | 28 canvas->translate(-srcRect.x(), -srcRect.y()); |
26 canvas->drawPicture(m_picture.get(), nullptr, &paint); | 29 canvas->drawPicture(m_picture.get(), nullptr, &paint); |
27 } | 30 } |
28 | 31 |
29 void PaintGeneratedImage::drawTile(GraphicsContext& context, | 32 void PaintGeneratedImage::drawTile(GraphicsContext& context, |
30 const FloatRect& srcRect) { | 33 const FloatRect& srcRect) { |
| 34 // TODO(ccameron): This function should not ignore |context|'s color behavior. |
| 35 // https://crbug.com/672306 |
31 context.drawPicture(m_picture.get()); | 36 context.drawPicture(m_picture.get()); |
32 } | 37 } |
33 | 38 |
34 } // namespace blink | 39 } // namespace blink |
OLD | NEW |