| 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 "skia/ext/cdl_canvas.h" |
| 7 #include "platform/graphics/ImageBuffer.h" | 8 #include "platform/graphics/ImageBuffer.h" |
| 8 #include <memory> | 9 #include <memory> |
| 9 | 10 |
| 10 namespace blink { | 11 namespace blink { |
| 11 | 12 |
| 12 PaintRenderingContext2D::PaintRenderingContext2D( | 13 PaintRenderingContext2D::PaintRenderingContext2D( |
| 13 std::unique_ptr<ImageBuffer> imageBuffer, | 14 std::unique_ptr<ImageBuffer> imageBuffer, |
| 14 bool hasAlpha, | 15 bool hasAlpha, |
| 15 float zoom) | 16 float zoom) |
| 16 : m_imageBuffer(std::move(imageBuffer)), m_hasAlpha(hasAlpha) { | 17 : m_imageBuffer(std::move(imageBuffer)), m_hasAlpha(hasAlpha) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 40 bool PaintRenderingContext2D::parseColorOrCurrentColor( | 41 bool PaintRenderingContext2D::parseColorOrCurrentColor( |
| 41 Color& color, | 42 Color& color, |
| 42 const String& colorString) const { | 43 const String& colorString) const { |
| 43 // We ignore "currentColor" for PaintRenderingContext2D and just make it | 44 // We ignore "currentColor" for PaintRenderingContext2D and just make it |
| 44 // "black". "currentColor" can be emulated by having "color" as an input | 45 // "black". "currentColor" can be emulated by having "color" as an input |
| 45 // property for the css-paint-api. | 46 // property for the css-paint-api. |
| 46 // https://github.com/w3c/css-houdini-drafts/issues/133 | 47 // https://github.com/w3c/css-houdini-drafts/issues/133 |
| 47 return ::blink::parseColorOrCurrentColor(color, colorString, nullptr); | 48 return ::blink::parseColorOrCurrentColor(color, colorString, nullptr); |
| 48 } | 49 } |
| 49 | 50 |
| 50 SkCanvas* PaintRenderingContext2D::drawingCanvas() const { | 51 CdlCanvas* PaintRenderingContext2D::drawingCanvas() const { |
| 51 return m_imageBuffer->canvas(); | 52 return m_imageBuffer->canvas(); |
| 52 } | 53 } |
| 53 | 54 |
| 54 SkCanvas* PaintRenderingContext2D::existingDrawingCanvas() const { | 55 CdlCanvas* PaintRenderingContext2D::existingDrawingCanvas() const { |
| 55 ASSERT(m_imageBuffer); | 56 ASSERT(m_imageBuffer); |
| 56 return m_imageBuffer->canvas(); | 57 return m_imageBuffer->canvas(); |
| 57 } | 58 } |
| 58 | 59 |
| 59 AffineTransform PaintRenderingContext2D::baseTransform() const { | 60 AffineTransform PaintRenderingContext2D::baseTransform() const { |
| 60 ASSERT(m_imageBuffer); | 61 ASSERT(m_imageBuffer); |
| 61 return m_imageBuffer->baseTransform(); | 62 return m_imageBuffer->baseTransform(); |
| 62 } | 63 } |
| 63 | 64 |
| 64 void PaintRenderingContext2D::didDraw(const SkIRect& dirtyRect) { | 65 void PaintRenderingContext2D::didDraw(const SkIRect& dirtyRect) { |
| 65 ASSERT(m_imageBuffer); | 66 ASSERT(m_imageBuffer); |
| 66 return m_imageBuffer->didDraw(SkRect::Make(dirtyRect)); | 67 return m_imageBuffer->didDraw(SkRect::Make(dirtyRect)); |
| 67 } | 68 } |
| 68 | 69 |
| 69 void PaintRenderingContext2D::validateStateStack() const { | 70 void PaintRenderingContext2D::validateStateStack() const { |
| 70 #if DCHECK_IS_ON() | 71 #if DCHECK_IS_ON() |
| 71 if (SkCanvas* skCanvas = existingDrawingCanvas()) { | 72 if (CdlCanvas* skCanvas = existingDrawingCanvas()) { |
| 72 DCHECK_EQ(static_cast<size_t>(skCanvas->getSaveCount()), | 73 DCHECK_EQ(static_cast<size_t>(skCanvas->getSaveCount()), |
| 73 m_stateStack.size() + 1); | 74 m_stateStack.size() + 1); |
| 74 } | 75 } |
| 75 #endif | 76 #endif |
| 76 } | 77 } |
| 77 | 78 |
| 78 } // namespace blink | 79 } // namespace blink |
| OLD | NEW |