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 "platform/graphics/paint/PaintRecord.h" | 9 #include "platform/graphics/paint/PaintRecord.h" |
10 | 10 |
11 namespace blink { | 11 namespace blink { |
12 | 12 |
13 void PaintGeneratedImage::Draw(PaintCanvas* canvas, | 13 void PaintGeneratedImage::Draw(PaintCanvas* canvas, |
14 const PaintFlags& flags, | 14 const PaintFlags& flags, |
15 const FloatRect& dest_rect, | 15 const FloatRect& dest_rect, |
16 const FloatRect& src_rect, | 16 const FloatRect& src_rect, |
17 RespectImageOrientationEnum, | 17 RespectImageOrientationEnum, |
18 ImageClampingMode) { | 18 ImageClampingMode) { |
19 PaintCanvasAutoRestore ar(canvas, true); | 19 PaintCanvasAutoRestore ar(canvas, true); |
20 canvas->clipRect(dest_rect); | 20 canvas->clipRect(dest_rect); |
21 canvas->translate(dest_rect.X(), dest_rect.Y()); | 21 canvas->translate(dest_rect.X(), dest_rect.Y()); |
22 if (dest_rect.Size() != src_rect.Size()) | 22 if (dest_rect.Size() != src_rect.Size()) |
23 canvas->scale(dest_rect.Width() / src_rect.Width(), | 23 canvas->scale(dest_rect.Width() / src_rect.Width(), |
24 dest_rect.Height() / src_rect.Height()); | 24 dest_rect.Height() / src_rect.Height()); |
25 canvas->translate(-src_rect.X(), -src_rect.Y()); | 25 canvas->translate(-src_rect.X(), -src_rect.Y()); |
26 SkRect bounds = record_->cullRect(); | 26 SkRect bounds = dest_rect; |
27 canvas->saveLayer(&bounds, &flags); | 27 canvas->saveLayer(&bounds, &flags); |
28 canvas->drawPicture(record_); | 28 canvas->drawPicture(record_); |
29 } | 29 } |
30 | 30 |
31 void PaintGeneratedImage::DrawTile(GraphicsContext& context, | 31 void PaintGeneratedImage::DrawTile(GraphicsContext& context, |
32 const FloatRect& src_rect) { | 32 const FloatRect& src_rect) { |
33 context.DrawRecord(record_); | 33 context.DrawRecord(record_); |
34 } | 34 } |
35 | 35 |
36 } // namespace blink | 36 } // namespace blink |
OLD | NEW |