forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ash: Add a PresentationTimeRecorder interface
- Add a PresentationTimeRecorder interface; - Add a factory to create a wrapper for ui::PresentationTimeRecorder; - Revise WindowStateDelegate::OnDragStart to optionally return a recorder to track resize latency. This allows exo code that implements WindowStateDelegate to return a recorder to track exo timing. Bug: 1249765 Change-Id: I41ae6247e677dd4c7435f50835973789d3dff11d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3550133 Reviewed-by: Mitsuru Oshima <oshima@chromium.org> Commit-Queue: Xiyuan Xia <xiyuan@chromium.org> Cr-Commit-Position: refs/heads/main@{#986536}
- Loading branch information
Xiyuan Xia
authored and
Chromium LUCI CQ
committed
Mar 29, 2022
1 parent
d3b4b75
commit e3b8049
Showing
14 changed files
with
142 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright 2022 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "ash/public/cpp/presentation_time_recorder.h" | ||
|
||
#include <memory> | ||
|
||
#include "ui/aura/window.h" | ||
#include "ui/compositor/layer.h" | ||
#include "ui/compositor/presentation_time_recorder.h" | ||
|
||
namespace ash { | ||
|
||
namespace { | ||
|
||
// Wrapper class of ui::PresentationTimeRecorder that reports latency based | ||
// on ui::Compositor. | ||
class CompositorPresentationTimeRecorder : public PresentationTimeRecorder { | ||
public: | ||
CompositorPresentationTimeRecorder(aura::Window* window, | ||
const char* latency_histogram_name, | ||
const char* max_latency_histogram_name) | ||
: compositor_recorder_(ui::CreatePresentationTimeHistogramRecorder( | ||
window->layer()->GetCompositor(), | ||
latency_histogram_name, | ||
max_latency_histogram_name)) {} | ||
|
||
CompositorPresentationTimeRecorder( | ||
const CompositorPresentationTimeRecorder&) = delete; | ||
CompositorPresentationTimeRecorder& operator=( | ||
const CompositorPresentationTimeRecorder&) = delete; | ||
|
||
~CompositorPresentationTimeRecorder() override = default; | ||
|
||
// PresentationTimeRecorder: | ||
bool RequestNext() override { return compositor_recorder_->RequestNext(); } | ||
|
||
private: | ||
std::unique_ptr<ui::PresentationTimeRecorder> compositor_recorder_; | ||
}; | ||
|
||
} // namespace | ||
|
||
// static | ||
std::unique_ptr<PresentationTimeRecorder> | ||
PresentationTimeRecorder::CreateCompositorRecorder( | ||
aura::Window* window, | ||
const char* latency_histogram_name, | ||
absl::optional<const char*> max_latency_histogram_name) { | ||
return std::make_unique<CompositorPresentationTimeRecorder>( | ||
window, latency_histogram_name, | ||
max_latency_histogram_name.has_value() | ||
? max_latency_histogram_name.value() | ||
: ""); | ||
} | ||
|
||
} // namespace ash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright 2022 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef ASH_PUBLIC_CPP_PRESENTATION_TIME_RECORDER_H_ | ||
#define ASH_PUBLIC_CPP_PRESENTATION_TIME_RECORDER_H_ | ||
|
||
#include <memory> | ||
|
||
#include "ash/public/cpp/ash_public_export.h" | ||
#include "third_party/abseil-cpp/absl/types/optional.h" | ||
|
||
namespace aura { | ||
class Window; | ||
} | ||
|
||
namespace ash { | ||
|
||
// A general interface for presentation time recording. | ||
class ASH_PUBLIC_EXPORT PresentationTimeRecorder { | ||
public: | ||
// Creates a recorder tracking ui::Compositor. | ||
static std::unique_ptr<PresentationTimeRecorder> CreateCompositorRecorder( | ||
aura::Window* window, | ||
const char* latency_histogram_name, | ||
absl::optional<const char*> max_latency_histogram_name = absl::nullopt); | ||
|
||
virtual ~PresentationTimeRecorder() = default; | ||
|
||
// Request to record timing for the next frame. Returns true if the request | ||
// is accepted. Otherwise, returns false. | ||
virtual bool RequestNext() = 0; | ||
}; | ||
|
||
} // namespace ash | ||
|
||
#endif // ASH_PUBLIC_CPP_PRESENTATION_TIME_RECORDER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters