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 "modules/csspaint/PaintRenderingContext2D.h" | 5 #include "modules/csspaint/PaintRenderingContext2D.h" |
6 | 6 |
7 #include "platform/graphics/ImageBuffer.h" | 7 #include "platform/graphics/ImageBuffer.h" |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 namespace blink { | 10 namespace blink { |
11 | 11 |
12 PaintRenderingContext2D::PaintRenderingContext2D( | 12 PaintRenderingContext2D::PaintRenderingContext2D( |
13 std::unique_ptr<ImageBuffer> imageBuffer, | 13 std::unique_ptr<ImageBuffer> imageBuffer, |
14 bool hasAlpha, | 14 bool hasAlpha, |
15 float zoom) | 15 float zoom) |
16 : m_imageBuffer(std::move(imageBuffer)), m_hasAlpha(hasAlpha) { | 16 : m_imageBuffer(std::move(imageBuffer)), m_hasAlpha(hasAlpha) { |
17 m_clipAntialiasing = AntiAliased; | 17 m_clipAntialiasing = AntiAliased; |
18 modifiableState().setShouldAntialias(true); | 18 modifiableState().setShouldAntialias(true); |
19 | 19 |
20 // RecordingImageBufferSurface doesn't call ImageBufferSurface::clear explicit
ly. | 20 // RecordingImageBufferSurface doesn't call ImageBufferSurface::clear |
| 21 // explicitly. |
21 DCHECK(m_imageBuffer); | 22 DCHECK(m_imageBuffer); |
22 m_imageBuffer->canvas()->clear(hasAlpha ? SK_ColorTRANSPARENT | 23 m_imageBuffer->canvas()->clear(hasAlpha ? SK_ColorTRANSPARENT |
23 : SK_ColorBLACK); | 24 : SK_ColorBLACK); |
24 m_imageBuffer->didDraw(FloatRect(0, 0, width(), height())); | 25 m_imageBuffer->didDraw(FloatRect(0, 0, width(), height())); |
25 | 26 |
26 m_imageBuffer->canvas()->scale(zoom, zoom); | 27 m_imageBuffer->canvas()->scale(zoom, zoom); |
27 } | 28 } |
28 | 29 |
29 int PaintRenderingContext2D::width() const { | 30 int PaintRenderingContext2D::width() const { |
30 ASSERT(m_imageBuffer); | 31 ASSERT(m_imageBuffer); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 #if ENABLE(ASSERT) | 70 #if ENABLE(ASSERT) |
70 SkCanvas* skCanvas = existingDrawingCanvas(); | 71 SkCanvas* skCanvas = existingDrawingCanvas(); |
71 if (skCanvas) { | 72 if (skCanvas) { |
72 ASSERT(static_cast<size_t>(skCanvas->getSaveCount()) == | 73 ASSERT(static_cast<size_t>(skCanvas->getSaveCount()) == |
73 m_stateStack.size()); | 74 m_stateStack.size()); |
74 } | 75 } |
75 #endif | 76 #endif |
76 } | 77 } |
77 | 78 |
78 } // namespace blink | 79 } // namespace blink |
OLD | NEW |