Index: Source/web/WebGraphicsContextImpl.h |
diff --git a/Source/web/WebGraphicsContextImpl.h b/Source/web/WebGraphicsContextImpl.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c4f695ab40b714aa529167d931050c4ab134e52d |
--- /dev/null |
+++ b/Source/web/WebGraphicsContextImpl.h |
@@ -0,0 +1,46 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
pdr.
2015/02/10 23:47:08
Can we combine this with WebGraphicsContext?
jbroman
2015/02/11 00:32:54
The interface/impl pattern seems to be more common
|
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef WebGraphicsContextImpl_h |
+#define WebGraphicsContextImpl_h |
+ |
+#include "platform/graphics/paint/DisplayItem.h" |
+#include "platform/graphics/paint/DisplayItemClient.h" |
+#include "public/web/WebGraphicsContext.h" |
+#include "wtf/OwnPtr.h" |
+ |
+namespace blink { |
+ |
+class DrawingRecorder; |
+class GraphicsContext; |
+ |
+// Wraps a blink::GraphicsContext. |
+// Internal consumers can extract the underlying context (via WebGraphicsContextImpl). |
+// External consumers can make a single drawing using a WebCanvas. |
+class WebGraphicsContextImpl : public WebGraphicsContext { |
+public: |
+ WebGraphicsContextImpl(GraphicsContext&, DisplayItemClient, DisplayItem::Type); |
+ ~WebGraphicsContextImpl(); |
+ GraphicsContext& graphicsContext() { return m_graphicsContext; } |
+ |
+ // blink::WebGraphicsContext |
+ WebCanvas* beginDrawing(const WebFloatRect& bounds) override; |
+ void endDrawing() override; |
+ |
+private: |
+ GraphicsContext& m_graphicsContext; |
+ DisplayItemClient m_client; |
+ DisplayItem::Type m_type; |
+ OwnPtr<DrawingRecorder> m_drawingRecorder; |
+#ifndef NDEBUG |
+ bool m_hasBegunDrawing; |
+#endif |
+}; |
+ |
+// Source/web/ assumes that WebGraphicsContextImpl is the only implementation. |
+DEFINE_TYPE_CASTS(WebGraphicsContextImpl, WebGraphicsContext, webGraphicsContext, true, true); |
+ |
+} // namespace blink |
+ |
+#endif |