Chromium Code Reviews| Index: third_party/WebKit/Source/platform/graphics/paint/PaintArtifact.h |
| diff --git a/third_party/WebKit/Source/platform/graphics/paint/PaintArtifact.h b/third_party/WebKit/Source/platform/graphics/paint/PaintArtifact.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a4e37c4c94b2556323a2990afdc1defc9538ef5a |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/platform/graphics/paint/PaintArtifact.h |
| @@ -0,0 +1,64 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef PaintArtifact_h |
| +#define PaintArtifact_h |
| + |
| +#include "platform/PlatformExport.h" |
| +#include "platform/graphics/paint/DisplayItems.h" |
| +#include "platform/graphics/paint/PaintChunk.h" |
| +#include "wtf/Vector.h" |
| + |
| +namespace blink { |
| + |
| +class GraphicsContext; |
| +class WebDisplayItemList; |
| + |
| +// The output of painting, consisting of a series of drawings partitioned into |
| +// discontiguous chunks with a common set of paint properties (i.e. associated |
|
wkorman
2015/10/09 04:45:50
Does the order of chunks in the vector matter / is
|
| +// with the same transform, clip, effects, etc.). |
| +// |
| +// It represents a particular state of the world, and should be immutable |
| +// (const) to most of its users. |
| +class PLATFORM_EXPORT PaintArtifact { |
| +public: |
| + PaintArtifact(); |
| + ~PaintArtifact(); |
| + |
| + bool isEmpty() const { return m_displayItems.isEmpty(); } |
| + |
| + DisplayItems& displayItems() { return m_displayItems; } |
| + const DisplayItems& displayItems() const { return m_displayItems; } |
| + |
| + Vector<PaintChunk>& paintChunks() { return m_paintChunks; } |
| + const Vector<PaintChunk>& paintChunks() const { return m_paintChunks; } |
| + |
| + // Resets to an empty paint artifact. |
| + void reset(); |
| + |
| + // Updates the artifact with complete display items and chunks. |
| + // This swaps out of the display items, making it empty. |
| + // This will be more efficient if you pass an rvalue for updatedPaintChunks |
| + // to avoid a copy. |
| + // TODO(jbroman): Clean this up once std::move is legal in Blink. |
| + void update(DisplayItems& updatedDisplayItems, Vector<PaintChunk> updatedPaintChunks); |
|
pdr.
2015/10/09 03:57:51
I think it would be best to leave this in the clas
jbroman
2015/10/13 18:20:56
I waffled on this point, so I'll mail you a CL to
|
| + |
| + // Returns the approximate memory usage, excluding memory likely to be |
| + // shared with the embedder after copying to WebDisplayItemList. |
| + size_t approximateUnsharedMemoryUsage() const; |
| + |
| + // Draws the paint artifact to a GraphicsContext. |
| + void replay(GraphicsContext&) const; |
| + |
| + // Writes the paint artifact into a WebDisplayItemList. |
| + void appendToWebDisplayItemList(WebDisplayItemList*) const; |
| + |
| +private: |
| + DisplayItems m_displayItems; |
| + Vector<PaintChunk> m_paintChunks; |
| +}; |
| + |
| +} // namespace blink |
| + |
| +#endif // PaintArtifact_h |