OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "modules/csspaint/PaintRenderingContext2D.h" |
| 6 |
| 7 #include "platform/graphics/ImageBuffer.h" |
| 8 |
| 9 namespace blink { |
| 10 |
| 11 PaintRenderingContext2D::PaintRenderingContext2D(PassOwnPtr<ImageBuffer> imageBu
ffer) |
| 12 : m_imageBuffer(imageBuffer) |
| 13 { |
| 14 m_clipAntialiasing = AntiAliased; |
| 15 modifiableState().setShouldAntialias(true); |
| 16 } |
| 17 |
| 18 int PaintRenderingContext2D::width() const |
| 19 { |
| 20 ASSERT(m_imageBuffer); |
| 21 return m_imageBuffer->size().width(); |
| 22 } |
| 23 |
| 24 int PaintRenderingContext2D::height() const |
| 25 { |
| 26 ASSERT(m_imageBuffer); |
| 27 return m_imageBuffer->size().height(); |
| 28 } |
| 29 |
| 30 bool PaintRenderingContext2D::parseColorOrCurrentColor(Color& color, const Strin
g& colorString) const |
| 31 { |
| 32 // We ignore "currentColor" for PaintRenderingContext2D, this would get |
| 33 // passed into css-paint-api as a resolved typed-om <color> object. |
| 34 // https://github.com/w3c/css-houdini-drafts/issues/133 |
| 35 return parseColorOnly(color, colorString); |
| 36 } |
| 37 |
| 38 SkCanvas* PaintRenderingContext2D::drawingCanvas() const |
| 39 { |
| 40 return m_imageBuffer->canvas(); |
| 41 } |
| 42 |
| 43 SkCanvas* PaintRenderingContext2D::existingDrawingCanvas() const |
| 44 { |
| 45 ASSERT(m_imageBuffer); |
| 46 return m_imageBuffer->canvas(); |
| 47 } |
| 48 |
| 49 AffineTransform PaintRenderingContext2D::baseTransform() const |
| 50 { |
| 51 ASSERT(m_imageBuffer); |
| 52 return m_imageBuffer->baseTransform(); |
| 53 } |
| 54 |
| 55 void PaintRenderingContext2D::didDraw(const SkIRect& dirtyRect) |
| 56 { |
| 57 ASSERT(m_imageBuffer); |
| 58 return m_imageBuffer->didDraw(SkRect::Make(dirtyRect)); |
| 59 } |
| 60 |
| 61 void PaintRenderingContext2D::validateStateStack() |
| 62 { |
| 63 #if ENABLE(ASSERT) |
| 64 SkCanvas* skCanvas = existingDrawingCanvas(); |
| 65 if (skCanvas) { |
| 66 ASSERT(static_cast<size_t>(skCanvas->getSaveCount()) == m_stateStack.siz
e()); |
| 67 } |
| 68 #endif |
| 69 } |
| 70 |
| 71 } // namespace blink |
OLD | NEW |