mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-14 22:30:40 +01:00
Adds debug logs which warns about cursor flickering
Main issue is https://chromium-review.googlesource.com/c/chromium/src/+/4507078 Bug: chromium:1421656 Change-Id: I61c6df59176e10bc29356ea924a4e483270db75f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/304284 Reviewed-by: Alexander Cooper <alcooper@chromium.org> Commit-Queue: Henrik Andreassson <henrika@webrtc.org> Cr-Commit-Position: refs/heads/main@{#40038}
This commit is contained in:
parent
cf75442ad3
commit
2d7424305d
1 changed files with 17 additions and 10 deletions
|
@ -27,6 +27,17 @@ namespace webrtc {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
// Global reference counter which is increased when a DesktopFrameWithCursor is
|
||||||
|
// created and decreased when the same object is destructed. Only used for
|
||||||
|
// debugging purposes to ensure that we never end up in state where
|
||||||
|
// `g_ref_count` is larger than one since that could indicate a flickering
|
||||||
|
// cursor (cursor-less version of the frame is not restored properly and it can
|
||||||
|
// can lead to visible trails of old cursors).
|
||||||
|
// See https://crbug.com/1421656#c99 for more details.
|
||||||
|
int g_ref_count = 0;
|
||||||
|
|
||||||
|
uint64_t g_num_flicker_warnings = 0;
|
||||||
|
|
||||||
// Helper function that blends one image into another. Source image must be
|
// Helper function that blends one image into another. Source image must be
|
||||||
// pre-multiplied with the alpha channel. Destination is assumed to be opaque.
|
// pre-multiplied with the alpha channel. Destination is assumed to be opaque.
|
||||||
void AlphaBlend(uint8_t* dest,
|
void AlphaBlend(uint8_t* dest,
|
||||||
|
@ -96,6 +107,7 @@ DesktopFrameWithCursor::DesktopFrameWithCursor(
|
||||||
frame->data(),
|
frame->data(),
|
||||||
frame->shared_memory()),
|
frame->shared_memory()),
|
||||||
original_frame_(std::move(frame)) {
|
original_frame_(std::move(frame)) {
|
||||||
|
++g_ref_count;
|
||||||
MoveFrameInfoFrom(original_frame_.get());
|
MoveFrameInfoFrom(original_frame_.get());
|
||||||
|
|
||||||
DesktopVector image_pos = position.subtract(cursor.hotspot());
|
DesktopVector image_pos = position.subtract(cursor.hotspot());
|
||||||
|
@ -105,11 +117,6 @@ DesktopFrameWithCursor::DesktopFrameWithCursor(
|
||||||
cursor_rect_.IntersectWith(DesktopRect::MakeSize(size()));
|
cursor_rect_.IntersectWith(DesktopRect::MakeSize(size()));
|
||||||
|
|
||||||
if (!previous_cursor_rect.equals(cursor_rect_)) {
|
if (!previous_cursor_rect.equals(cursor_rect_)) {
|
||||||
RTC_LOG(LS_VERBOSE) << "[MOUSE] cursors moved => cursor_rect=("
|
|
||||||
<< cursor_rect_.top_left().x() << ","
|
|
||||||
<< cursor_rect_.top_left().y() << ") ("
|
|
||||||
<< cursor_rect_.size().width() << "x"
|
|
||||||
<< cursor_rect_.size().height() << ")";
|
|
||||||
mutable_updated_region()->AddRect(cursor_rect_);
|
mutable_updated_region()->AddRect(cursor_rect_);
|
||||||
// TODO(crbug:1323241) Update this code to properly handle the case where
|
// TODO(crbug:1323241) Update this code to properly handle the case where
|
||||||
// |previous_cursor_rect| is outside of the boundaries of |frame|.
|
// |previous_cursor_rect| is outside of the boundaries of |frame|.
|
||||||
|
@ -118,11 +125,6 @@ DesktopFrameWithCursor::DesktopFrameWithCursor(
|
||||||
// we're running on.
|
// we're running on.
|
||||||
mutable_updated_region()->AddRect(previous_cursor_rect);
|
mutable_updated_region()->AddRect(previous_cursor_rect);
|
||||||
} else if (cursor_changed) {
|
} else if (cursor_changed) {
|
||||||
RTC_LOG(LS_VERBOSE) << "[MOUSE] cursor changed => cursor_rect=("
|
|
||||||
<< cursor_rect_.top_left().x() << ","
|
|
||||||
<< cursor_rect_.top_left().y() << ") ("
|
|
||||||
<< cursor_rect_.size().width() << "x"
|
|
||||||
<< cursor_rect_.size().height() << ")";
|
|
||||||
mutable_updated_region()->AddRect(cursor_rect_);
|
mutable_updated_region()->AddRect(cursor_rect_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,6 +150,11 @@ DesktopFrameWithCursor::DesktopFrameWithCursor(
|
||||||
}
|
}
|
||||||
|
|
||||||
DesktopFrameWithCursor::~DesktopFrameWithCursor() {
|
DesktopFrameWithCursor::~DesktopFrameWithCursor() {
|
||||||
|
if (--g_ref_count > 0) {
|
||||||
|
++g_num_flicker_warnings;
|
||||||
|
RTC_LOG(LS_WARNING) << "Cursor might be flickering; number of warnings="
|
||||||
|
<< g_num_flicker_warnings;
|
||||||
|
}
|
||||||
// Restore original content of the frame.
|
// Restore original content of the frame.
|
||||||
if (restore_frame_) {
|
if (restore_frame_) {
|
||||||
DesktopRect target_rect = DesktopRect::MakeSize(restore_frame_->size());
|
DesktopRect target_rect = DesktopRect::MakeSize(restore_frame_->size());
|
||||||
|
|
Loading…
Reference in a new issue