1 // Copyright 2015 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.
5 #ifndef WebGraphicsContextImpl_h
6 #define WebGraphicsContextImpl_h
8 #include "platform/graphics/paint/DisplayItem.h"
9 #include "platform/graphics/paint/DisplayItemClient.h"
10 #include "public/web/WebGraphicsContext.h"
11 #include "wtf/OwnPtr.h"
15 class DrawingRecorder
;
16 class GraphicsContext
;
18 // Wraps a blink::GraphicsContext.
19 // Internal consumers can extract the underlying context (via WebGraphicsContextImpl).
20 // External consumers can make a single drawing using a WebCanvas.
21 class WebGraphicsContextImpl
: public WebGraphicsContext
{
23 WebGraphicsContextImpl(GraphicsContext
&, const DisplayItemClientWrapper
&, DisplayItem::Type
);
24 ~WebGraphicsContextImpl();
25 GraphicsContext
& graphicsContext() { return m_graphicsContext
; }
27 // blink::WebGraphicsContext
28 WebCanvas
* beginDrawing(const WebFloatRect
& bounds
) override
;
29 void endDrawing() override
;
32 GraphicsContext
& m_graphicsContext
;
33 DisplayItemClientWrapper m_client
;
34 DisplayItem::Type m_type
;
35 OwnPtr
<DrawingRecorder
> m_drawingRecorder
;
37 bool m_hasBegunDrawing
;
41 // Source/web/ assumes that WebGraphicsContextImpl is the only implementation.
42 DEFINE_TYPE_CASTS(WebGraphicsContextImpl
, WebGraphicsContext
, webGraphicsContext
, true, true);