browser(webkit): dedupe screencast frames (#9386)
This commit is contained in:
parent
120e919b8e
commit
349f3444e6
|
|
@ -1,2 +1,2 @@
|
|||
1558
|
||||
Changed: yurys@chromium.org Tue 05 Oct 2021 03:13:20 PM PDT
|
||||
1559
|
||||
Changed: pavel.feldman@gmail.com Thu 07 Oct 2021 06:57:27 PM PDT
|
||||
|
|
|
|||
|
|
@ -13438,10 +13438,10 @@ index 0000000000000000000000000000000000000000..4ec8b96bbbddf8a7b042f53a8068754a
|
|||
+cairo_status_t cairo_image_surface_write_to_jpeg_mem(cairo_surface_t *sfc, unsigned char **data, size_t *len, int quality);
|
||||
diff --git a/Source/WebKit/UIProcess/Inspector/Agents/InspectorScreencastAgent.cpp b/Source/WebKit/UIProcess/Inspector/Agents/InspectorScreencastAgent.cpp
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..20122bd89c3ba0ec4ff878ac895bddd497cc9789
|
||||
index 0000000000000000000000000000000000000000..9a1547d6ad27f58d8276b657c6c7190ebc6b75dc
|
||||
--- /dev/null
|
||||
+++ b/Source/WebKit/UIProcess/Inspector/Agents/InspectorScreencastAgent.cpp
|
||||
@@ -0,0 +1,269 @@
|
||||
@@ -0,0 +1,284 @@
|
||||
+/*
|
||||
+ * Copyright (C) 2020 Microsoft Corporation.
|
||||
+ *
|
||||
|
|
@ -13476,6 +13476,7 @@ index 0000000000000000000000000000000000000000..20122bd89c3ba0ec4ff878ac895bddd4
|
|||
+#include "WebPageInspectorController.h"
|
||||
+#include "WebPageProxy.h"
|
||||
+#include "WebsiteDataStore.h"
|
||||
+#include <pal/crypto/CryptoDigest.h>
|
||||
+#include <JavaScriptCore/InspectorFrontendRouter.h>
|
||||
+#include <WebCore/NotImplemented.h>
|
||||
+#include <wtf/RunLoop.h>
|
||||
|
|
@ -13534,6 +13535,20 @@ index 0000000000000000000000000000000000000000..20122bd89c3ba0ec4ff878ac895bddd4
|
|||
+ if (m_encoder)
|
||||
+ m_encoder->encodeFrame(surface, m_page.drawingArea()->size());
|
||||
+ if (m_screencast) {
|
||||
+
|
||||
+ {
|
||||
+ // Do not send the same frame over and over.
|
||||
+ unsigned char *data = cairo_image_surface_get_data(surface);
|
||||
+ int stride = cairo_image_surface_get_stride(surface);
|
||||
+ int height = cairo_image_surface_get_height(surface);
|
||||
+ auto cryptoDigest = PAL::CryptoDigest::create(PAL::CryptoDigest::Algorithm::SHA_1);
|
||||
+ cryptoDigest->addBytes(data, stride * height);
|
||||
+ auto digest = cryptoDigest->computeHash();
|
||||
+ if (m_lastFrameDigest == digest)
|
||||
+ return;
|
||||
+ m_lastFrameDigest = digest;
|
||||
+ }
|
||||
+
|
||||
+ if (m_screencastFramesInFlight > kMaxFramesInFlight)
|
||||
+ return;
|
||||
+ // Scale image to fit width / height
|
||||
|
|
@ -13713,10 +13728,10 @@ index 0000000000000000000000000000000000000000..20122bd89c3ba0ec4ff878ac895bddd4
|
|||
+} // namespace WebKit
|
||||
diff --git a/Source/WebKit/UIProcess/Inspector/Agents/InspectorScreencastAgent.h b/Source/WebKit/UIProcess/Inspector/Agents/InspectorScreencastAgent.h
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..8f2795dbf1323dd8d5f986f18e6fe16431dd7f70
|
||||
index 0000000000000000000000000000000000000000..a45b32a1c839cf019fcece2f950e595d89d93fa7
|
||||
--- /dev/null
|
||||
+++ b/Source/WebKit/UIProcess/Inspector/Agents/InspectorScreencastAgent.h
|
||||
@@ -0,0 +1,96 @@
|
||||
@@ -0,0 +1,97 @@
|
||||
+/*
|
||||
+ * Copyright (C) 2020 Microsoft Corporation.
|
||||
+ *
|
||||
|
|
@ -13800,6 +13815,7 @@ index 0000000000000000000000000000000000000000..8f2795dbf1323dd8d5f986f18e6fe164
|
|||
+ std::unique_ptr<Inspector::ScreencastFrontendDispatcher> m_frontendDispatcher;
|
||||
+ Ref<Inspector::ScreencastBackendDispatcher> m_backendDispatcher;
|
||||
+ WebPageProxy& m_page;
|
||||
+ Vector<uint8_t> m_lastFrameDigest;
|
||||
+ RefPtr<ScreencastEncoder> m_encoder;
|
||||
+ bool m_screencast = false;
|
||||
+ bool m_framesAreGoing = false;
|
||||
|
|
|
|||
Loading…
Reference in a new issue