Title: [229454] trunk/Source/WebCore
- Revision
- 229454
- Author
- [email protected]
- Date
- 2018-03-08 23:50:26 -0800 (Thu, 08 Mar 2018)
Log Message
Add basic synchronization capability to Nicosia::Buffer
https://bugs.webkit.org/show_bug.cgi?id=183500
Reviewed by Carlos Garcia Campos.
Have Nicosia::Buffer track a painting state, and allow that state to be
modified and accessed from different threads. The PaintingState enum
value is protected by a Lock object, and can be modified via the
beginPainting() and completePainting() methods. Additionally, the
waitUntilPaintingComplete() method allows the caller to wait until the
painting is complete for the given Nicosia::Buffer object.
This added state doesn't affect a Nicosia::Buffer object internally, and
doesn't have any effect on existing usages of Nicosia::Buffer (which
are not multi-threaded).
* platform/graphics/nicosia/NicosiaBuffer.cpp:
(Nicosia::Buffer::beginPainting):
(Nicosia::Buffer::completePainting):
(Nicosia::Buffer::waitUntilPaintingComplete):
* platform/graphics/nicosia/NicosiaBuffer.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (229453 => 229454)
--- trunk/Source/WebCore/ChangeLog 2018-03-09 07:42:34 UTC (rev 229453)
+++ trunk/Source/WebCore/ChangeLog 2018-03-09 07:50:26 UTC (rev 229454)
@@ -1,5 +1,29 @@
2018-03-08 Zan Dobersek <[email protected]>
+ Add basic synchronization capability to Nicosia::Buffer
+ https://bugs.webkit.org/show_bug.cgi?id=183500
+
+ Reviewed by Carlos Garcia Campos.
+
+ Have Nicosia::Buffer track a painting state, and allow that state to be
+ modified and accessed from different threads. The PaintingState enum
+ value is protected by a Lock object, and can be modified via the
+ beginPainting() and completePainting() methods. Additionally, the
+ waitUntilPaintingComplete() method allows the caller to wait until the
+ painting is complete for the given Nicosia::Buffer object.
+
+ This added state doesn't affect a Nicosia::Buffer object internally, and
+ doesn't have any effect on existing usages of Nicosia::Buffer (which
+ are not multi-threaded).
+
+ * platform/graphics/nicosia/NicosiaBuffer.cpp:
+ (Nicosia::Buffer::beginPainting):
+ (Nicosia::Buffer::completePainting):
+ (Nicosia::Buffer::waitUntilPaintingComplete):
+ * platform/graphics/nicosia/NicosiaBuffer.h:
+
+2018-03-08 Zan Dobersek <[email protected]>
+
Move NicosiaPaintingContextCairo files under Cairo-specific directory
https://bugs.webkit.org/show_bug.cgi?id=183497
Modified: trunk/Source/WebCore/platform/graphics/nicosia/NicosiaBuffer.cpp (229453 => 229454)
--- trunk/Source/WebCore/platform/graphics/nicosia/NicosiaBuffer.cpp 2018-03-09 07:42:34 UTC (rev 229453)
+++ trunk/Source/WebCore/platform/graphics/nicosia/NicosiaBuffer.cpp 2018-03-09 07:50:26 UTC (rev 229454)
@@ -52,4 +52,26 @@
Buffer::~Buffer() = default;
+void Buffer::beginPainting()
+{
+ LockHolder locker(m_painting.lock);
+ ASSERT(m_painting.state == PaintingState::Complete);
+ m_painting.state = PaintingState::InProgress;
+}
+
+void Buffer::completePainting()
+{
+ LockHolder locker(m_painting.lock);
+ ASSERT(m_painting.state == PaintingState::InProgress);
+ m_painting.state = PaintingState::Complete;
+ m_painting.condition.notifyOne();
+}
+
+void Buffer::waitUntilPaintingComplete()
+{
+ LockHolder locker(m_painting.lock);
+ m_painting.condition.wait(m_painting.lock,
+ [this] { return m_painting.state == PaintingState::Complete; });
+}
+
} // namespace Nicosia
Modified: trunk/Source/WebCore/platform/graphics/nicosia/NicosiaBuffer.h (229453 => 229454)
--- trunk/Source/WebCore/platform/graphics/nicosia/NicosiaBuffer.h 2018-03-09 07:42:34 UTC (rev 229453)
+++ trunk/Source/WebCore/platform/graphics/nicosia/NicosiaBuffer.h 2018-03-09 07:50:26 UTC (rev 229454)
@@ -29,6 +29,8 @@
#pragma once
#include "IntSize.h"
+#include <wtf/Condition.h>
+#include <wtf/Lock.h>
#include <wtf/MallocPtr.h>
#include <wtf/Ref.h>
#include <wtf/ThreadSafeRefCounted.h>
@@ -51,6 +53,10 @@
int stride() const { return m_size.width() * 4; }
unsigned char* data() const { return m_data.get(); }
+ void beginPainting();
+ void completePainting();
+ void waitUntilPaintingComplete();
+
private:
Buffer(const WebCore::IntSize&, Flags);
@@ -57,6 +63,17 @@
MallocPtr<unsigned char> m_data;
WebCore::IntSize m_size;
Flags m_flags;
+
+ enum class PaintingState {
+ InProgress,
+ Complete
+ };
+
+ struct {
+ Lock lock;
+ Condition condition;
+ PaintingState state { PaintingState::Complete };
+ } m_painting;
};
} // namespace Nicosia
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes