| 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 "platform/graphics/paint/PaintCanvas.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) { |
| 17 m_clipAntialiasing = AntiAliased; | 18 m_clipAntialiasing = AntiAliased; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 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 ColorBehavior PaintRenderingContext2D::drawImageColorBehavior() const { | 51 ColorBehavior PaintRenderingContext2D::drawImageColorBehavior() const { |
| 51 return ColorBehavior::transformToGlobalTarget(); | 52 return ColorBehavior::transformToGlobalTarget(); |
| 52 } | 53 } |
| 53 | 54 |
| 54 SkCanvas* PaintRenderingContext2D::drawingCanvas() const { | 55 PaintCanvas* PaintRenderingContext2D::drawingCanvas() const { |
| 55 return m_imageBuffer->canvas(); | 56 return m_imageBuffer->canvas(); |
| 56 } | 57 } |
| 57 | 58 |
| 58 SkCanvas* PaintRenderingContext2D::existingDrawingCanvas() const { | 59 PaintCanvas* PaintRenderingContext2D::existingDrawingCanvas() const { |
| 59 ASSERT(m_imageBuffer); | 60 ASSERT(m_imageBuffer); |
| 60 return m_imageBuffer->canvas(); | 61 return m_imageBuffer->canvas(); |
| 61 } | 62 } |
| 62 | 63 |
| 63 AffineTransform PaintRenderingContext2D::baseTransform() const { | 64 AffineTransform PaintRenderingContext2D::baseTransform() const { |
| 64 ASSERT(m_imageBuffer); | 65 ASSERT(m_imageBuffer); |
| 65 return m_imageBuffer->baseTransform(); | 66 return m_imageBuffer->baseTransform(); |
| 66 } | 67 } |
| 67 | 68 |
| 68 void PaintRenderingContext2D::didDraw(const SkIRect& dirtyRect) { | 69 void PaintRenderingContext2D::didDraw(const SkIRect& dirtyRect) { |
| 69 ASSERT(m_imageBuffer); | 70 ASSERT(m_imageBuffer); |
| 70 return m_imageBuffer->didDraw(SkRect::Make(dirtyRect)); | 71 return m_imageBuffer->didDraw(SkRect::Make(dirtyRect)); |
| 71 } | 72 } |
| 72 | 73 |
| 73 void PaintRenderingContext2D::validateStateStack() const { | 74 void PaintRenderingContext2D::validateStateStack() const { |
| 74 #if DCHECK_IS_ON() | 75 #if DCHECK_IS_ON() |
| 75 if (SkCanvas* skCanvas = existingDrawingCanvas()) { | 76 if (PaintCanvas* skCanvas = existingDrawingCanvas()) { |
| 76 DCHECK_EQ(static_cast<size_t>(skCanvas->getSaveCount()), | 77 DCHECK_EQ(static_cast<size_t>(skCanvas->getSaveCount()), |
| 77 m_stateStack.size() + 1); | 78 m_stateStack.size() + 1); |
| 78 } | 79 } |
| 79 #endif | 80 #endif |
| 80 } | 81 } |
| 81 | 82 |
| 82 } // namespace blink | 83 } // namespace blink |
| OLD | NEW |