Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(825)

Side by Side Diff: third_party/WebKit/Source/modules/csspaint/PaintRenderingContext2D.cpp

Issue 1778413003: Implement PaintRenderingContext2D off BaseRenderingContext2D (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 and just make it
33 // "black". "currentColor" can be emulated by having "color" as an input
34 // property for the css-paint-api.
35 // https://github.com/w3c/css-houdini-drafts/issues/133
36 return ::blink::parseColorOrCurrentColor(color, colorString, nullptr);
37 }
38
39 SkCanvas* PaintRenderingContext2D::drawingCanvas() const
40 {
41 return m_imageBuffer->canvas();
42 }
43
44 SkCanvas* PaintRenderingContext2D::existingDrawingCanvas() const
45 {
46 ASSERT(m_imageBuffer);
47 return m_imageBuffer->canvas();
48 }
49
50 AffineTransform PaintRenderingContext2D::baseTransform() const
51 {
52 ASSERT(m_imageBuffer);
53 return m_imageBuffer->baseTransform();
54 }
55
56 void PaintRenderingContext2D::didDraw(const SkIRect& dirtyRect)
57 {
58 ASSERT(m_imageBuffer);
59 return m_imageBuffer->didDraw(SkRect::Make(dirtyRect));
60 }
61
62 void PaintRenderingContext2D::validateStateStack()
63 {
64 #if ENABLE(ASSERT)
65 SkCanvas* skCanvas = existingDrawingCanvas();
66 if (skCanvas) {
67 ASSERT(static_cast<size_t>(skCanvas->getSaveCount()) == m_stateStack.siz e());
68 }
69 #endif
70 }
71
72 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698