Commit e92b7c2b authored by fs's avatar fs Committed by Commit bot

Lazily create the Path in StylePath

Instead of creating the Path object up front - when the StylePath is
created - create it on first access/use (usually on paint/layout.)

Review URL: https://codereview.chromium.org/1640313002

Cr-Commit-Position: refs/heads/master@{#371850}
parent 0965f08d
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "core/css/CSSPathValue.h" #include "core/css/CSSPathValue.h"
#include "core/svg/SVGPathByteStream.h" #include "core/svg/SVGPathByteStream.h"
#include "core/svg/SVGPathUtilities.h" #include "core/svg/SVGPathUtilities.h"
#include "platform/graphics/Path.h"
namespace blink { namespace blink {
...@@ -14,7 +15,6 @@ StylePath::StylePath(PassRefPtr<SVGPathByteStream> pathByteStream) ...@@ -14,7 +15,6 @@ StylePath::StylePath(PassRefPtr<SVGPathByteStream> pathByteStream)
: m_byteStream(pathByteStream) : m_byteStream(pathByteStream)
{ {
ASSERT(m_byteStream); ASSERT(m_byteStream);
buildPathFromByteStream(*m_byteStream, m_path);
} }
StylePath::~StylePath() StylePath::~StylePath()
...@@ -32,6 +32,15 @@ StylePath* StylePath::emptyPath() ...@@ -32,6 +32,15 @@ StylePath* StylePath::emptyPath()
return emptyPath; return emptyPath;
} }
const Path& StylePath::path() const
{
if (!m_path) {
m_path = adoptPtr(new Path);
buildPathFromByteStream(*m_byteStream, *m_path);
}
return *m_path;
}
const SVGPathByteStream& StylePath::byteStream() const const SVGPathByteStream& StylePath::byteStream() const
{ {
return *m_byteStream; return *m_byteStream;
......
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
#ifndef StylePath_h #ifndef StylePath_h
#define StylePath_h #define StylePath_h
#include "platform/graphics/Path.h"
#include "platform/heap/Handle.h" #include "platform/heap/Handle.h"
#include "wtf/OwnPtr.h"
#include "wtf/PassRefPtr.h" #include "wtf/PassRefPtr.h"
#include "wtf/RefCounted.h" #include "wtf/RefCounted.h"
#include "wtf/RefPtr.h" #include "wtf/RefPtr.h"
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
namespace blink { namespace blink {
class CSSValue; class CSSValue;
class Path;
class SVGPathByteStream; class SVGPathByteStream;
class StylePath : public RefCounted<StylePath> { class StylePath : public RefCounted<StylePath> {
...@@ -23,7 +24,7 @@ public: ...@@ -23,7 +24,7 @@ public:
static StylePath* emptyPath(); static StylePath* emptyPath();
const Path& path() const { return m_path; } const Path& path() const;
const SVGPathByteStream& byteStream() const; const SVGPathByteStream& byteStream() const;
PassRefPtrWillBeRawPtr<CSSValue> computedCSSValue() const; PassRefPtrWillBeRawPtr<CSSValue> computedCSSValue() const;
...@@ -34,7 +35,7 @@ private: ...@@ -34,7 +35,7 @@ private:
explicit StylePath(PassRefPtr<SVGPathByteStream>); explicit StylePath(PassRefPtr<SVGPathByteStream>);
RefPtr<SVGPathByteStream> m_byteStream; RefPtr<SVGPathByteStream> m_byteStream;
Path m_path; mutable OwnPtr<Path> m_path;
}; };
} // namespace blink } // namespace blink
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment