Skip to content

Commit 3cad857

Browse files
authored
browser(webkit): record screenast for non-accelerated compositing (#2418)
1 parent 8f350e4 commit 3cad857

File tree

2 files changed

+33
-19
lines changed

2 files changed

+33
-19
lines changed

browser_patches/webkit/BUILD_NUMBER

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1248
1+
1249

browser_patches/webkit/patches/bootstrap.diff

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8915,10 +8915,10 @@ index 0000000000000000000000000000000000000000..a957c3b2586d67caa78b96bb8644bab8
89158915
+} // namespace WebKit
89168916
diff --git a/Source/WebKit/UIProcess/Inspector/Agents/ScreencastEncoder.cpp b/Source/WebKit/UIProcess/Inspector/Agents/ScreencastEncoder.cpp
89178917
new file mode 100644
8918-
index 0000000000000000000000000000000000000000..05af437266cb8d561e848c63fdb4056e79c12ff0
8918+
index 0000000000000000000000000000000000000000..6e0c7ffce5201430c04c95247e812324ddd10d22
89198919
--- /dev/null
89208920
+++ b/Source/WebKit/UIProcess/Inspector/Agents/ScreencastEncoder.cpp
8921-
@@ -0,0 +1,344 @@
8921+
@@ -0,0 +1,335 @@
89228922
+/*
89238923
+ * Copyright (c) 2010, The WebM Project authors. All rights reserved.
89248924
+ * Copyright (c) 2013 The Chromium Authors. All rights reserved.
@@ -9072,13 +9072,6 @@ index 0000000000000000000000000000000000000000..05af437266cb8d561e848c63fdb4056e
90729072
+ fwrite(header, 1, 12, outfile);
90739073
+}
90749074
+
9075-
+void ivf_write_frame_size(FILE *outfile, size_t frame_size) {
9076-
+ char header[4];
9077-
+
9078-
+ mem_put_le32(header, (int)frame_size);
9079-
+ fwrite(header, 1, 4, outfile);
9080-
+}
9081-
+
90829075
+} // namespace
90839076
+
90849077
+class ScreencastEncoder::VPXCodec {
@@ -9097,7 +9090,8 @@ index 0000000000000000000000000000000000000000..05af437266cb8d561e848c63fdb4056e
90979090
+ vpx_codec_iter_t iter = nullptr;
90989091
+ const vpx_codec_cx_pkt_t *pkt = nullptr;
90999092
+ int flags = 0;
9100-
+ const vpx_codec_err_t res = vpx_codec_encode(&m_codec, img, m_frameCount, 1, flags, VPX_DL_REALTIME);
9093+
+ unsigned long duration = 1;
9094+
+ const vpx_codec_err_t res = vpx_codec_encode(&m_codec, img, m_pts, duration, flags, VPX_DL_REALTIME);
91019095
+ if (res != VPX_CODEC_OK) {
91029096
+ fprintf(stderr, "Failed to encode frame: %s\n", vpx_codec_error(&m_codec));
91039097
+ return false;
@@ -9107,17 +9101,16 @@ index 0000000000000000000000000000000000000000..05af437266cb8d561e848c63fdb4056e
91079101
+ while ((pkt = vpx_codec_get_cx_data(&m_codec, &iter)) != nullptr) {
91089102
+ gotPkts = true;
91099103
+
9110-
+ fprintf(stderr, " pkt->kind=%d\n", pkt->kind);
91119104
+ if (pkt->kind == VPX_CODEC_CX_FRAME_PKT) {
9112-
+ const int keyframe = (pkt->data.frame.flags & VPX_FRAME_IS_KEY) != 0;
9113-
+ ivf_write_frame_header(m_file, pkt->data.frame.pts, pkt->data.frame.sz);
9105+
+ ivf_write_frame_header(m_file, m_pts, pkt->data.frame.sz);
91149106
+ if (fwrite(pkt->data.frame.buf, 1, pkt->data.frame.sz, m_file) != pkt->data.frame.sz) {
91159107
+ fprintf(stderr, "Failed to write compressed frame\n");
91169108
+ return 0;
91179109
+ }
9118-
+
9110+
+ bool keyframe = (pkt->data.frame.flags & VPX_FRAME_IS_KEY) != 0;
9111+
+ fprintf(stderr, " %spts=%ld sz=%ld\n", keyframe ? "[K] " : "", pkt->data.frame.pts, pkt->data.frame.sz);
9112+
+ m_pts += pkt->data.frame.duration;
91199113
+ ++m_frameCount;
9120-
+ fprintf(stderr, " writtend frame (key=%d)\n", keyframe);
91219114
+ }
91229115
+ }
91239116
+
@@ -9143,6 +9136,7 @@ index 0000000000000000000000000000000000000000..05af437266cb8d561e848c63fdb4056e
91439136
+ vpx_codec_enc_cfg_t m_cfg;
91449137
+ FILE* m_file = nullptr;
91459138
+ int m_frameCount = 0;
9139+
+ int64_t m_pts;
91469140
+};
91479141
+
91489142
+ScreencastEncoder::ScreencastEncoder(std::unique_ptr<VPXCodec>&& vpxCodec)
@@ -9185,7 +9179,6 @@ index 0000000000000000000000000000000000000000..05af437266cb8d561e848c63fdb4056e
91859179
+ const int fps = 30;
91869180
+ cfg.g_timebase.num = 1;
91879181
+ cfg.g_timebase.den = fps;
9188-
+ cfg.rc_target_bitrate = 200;
91899182
+ cfg.g_error_resilient = VPX_ERROR_RESILIENT_DEFAULT;
91909183
+
91919184
+ vpx_codec_ctx_t codec;
@@ -9208,8 +9201,6 @@ index 0000000000000000000000000000000000000000..05af437266cb8d561e848c63fdb4056e
92089201
+void ScreencastEncoder::encodeFrame(cairo_surface_t* drawingAreaSurface)
92099202
+{
92109203
+ fprintf(stderr, "ScreencastEncoder::encodeFrame\n");
9211-
+ // fprintf(stderr, "cairo_surface_get_type(image)=%d CAIRO_SURFACE_TYPE_IMAGE=%d CAIRO_SURFACE_TYPE_XLIB=%d\n", cairo_surface_get_type(drawingAreaSurface), CAIRO_SURFACE_TYPE_IMAGE, CAIRO_SURFACE_TYPE_XLIB);
9212-
+ // fprintf(stderr, "cairo_image_surface_get_format(image)=%d CAIRO_FORMAT_ARGB32=%d\n", cairo_image_surface_get_format(drawingAreaSurface), CAIRO_FORMAT_ARGB32);
92139204
+
92149205
+ IntSize size = cairoSurfaceSize(drawingAreaSurface);
92159206
+ if (size.isZero()) {
@@ -12593,6 +12584,29 @@ index 964c6315e38f5e0a0303febce45b1e975054f0b4..117d8c7c74bc81b34cfc0fe2b11a5429
1259312584
#if HAVE(APP_SSO)
1259412585
UniqueRef<SOAuthorizationCoordinator> m_soAuthorizationCoordinator;
1259512586
#endif
12587+
diff --git a/Source/WebKit/UIProcess/cairo/BackingStoreCairo.cpp b/Source/WebKit/UIProcess/cairo/BackingStoreCairo.cpp
12588+
index dc0a70b8824afdc7ec3dd1f69f4d9b51942924f6..012bf01a2307986292589ab1808f1df05dc060f7 100644
12589+
--- a/Source/WebKit/UIProcess/cairo/BackingStoreCairo.cpp
12590+
+++ b/Source/WebKit/UIProcess/cairo/BackingStoreCairo.cpp
12591+
@@ -27,6 +27,7 @@
12592+
#include "config.h"
12593+
#include "BackingStore.h"
12594+
12595+
+#include "DrawingAreaProxyCoordinatedGraphics.h"
12596+
#include "ShareableBitmap.h"
12597+
#include "UpdateInfo.h"
12598+
#include "WebPageProxy.h"
12599+
@@ -72,6 +73,10 @@ void BackingStore::paint(cairo_t* context, const IntRect& rect)
12600+
cairo_rectangle(context, rect.x(), rect.y(), rect.width(), rect.height());
12601+
cairo_fill(context);
12602+
cairo_restore(context);
12603+
+#if PLATFORM(GTK)
12604+
+ if (auto* drawingArea = static_cast<DrawingAreaProxyCoordinatedGraphics*>(m_webPageProxy.drawingArea()))
12605+
+ drawingArea->didPaint(m_backend->surface());
12606+
+#endif
12607+
}
12608+
12609+
void BackingStore::incorporateUpdate(ShareableBitmap* bitmap, const UpdateInfo& updateInfo)
1259612610
diff --git a/Source/WebKit/UIProcess/geoclue/GeoclueGeolocationProvider.cpp b/Source/WebKit/UIProcess/geoclue/GeoclueGeolocationProvider.cpp
1259712611
index 7ba39332bce6e28f0f4b2f7acf636f835c54f486..7c3d8125df147b6049075491b12cce1dc84bf514 100644
1259812612
--- a/Source/WebKit/UIProcess/geoclue/GeoclueGeolocationProvider.cpp

0 commit comments

Comments
 (0)