summaryrefslogtreecommitdiff
path: root/chromium/components/viz/common/frame_sinks
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/components/viz/common/frame_sinks')
-rw-r--r--chromium/components/viz/common/frame_sinks/begin_frame_source.h2
-rw-r--r--chromium/components/viz/common/frame_sinks/copy_output_request.cc28
2 files changed, 18 insertions, 12 deletions
diff --git a/chromium/components/viz/common/frame_sinks/begin_frame_source.h b/chromium/components/viz/common/frame_sinks/begin_frame_source.h
index 8be3ad72924..2ca5c252021 100644
--- a/chromium/components/viz/common/frame_sinks/begin_frame_source.h
+++ b/chromium/components/viz/common/frame_sinks/begin_frame_source.h
@@ -10,8 +10,8 @@
#include <string>
+#include "base/check.h"
#include "base/containers/flat_set.h"
-#include "base/logging.h"
#include "base/macros.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
diff --git a/chromium/components/viz/common/frame_sinks/copy_output_request.cc b/chromium/components/viz/common/frame_sinks/copy_output_request.cc
index 1a10284b8af..ef836fb3a44 100644
--- a/chromium/components/viz/common/frame_sinks/copy_output_request.cc
+++ b/chromium/components/viz/common/frame_sinks/copy_output_request.cc
@@ -6,6 +6,8 @@
#include "base/bind.h"
#include "base/check_op.h"
+#include "base/task/task_traits.h"
+#include "base/task/thread_pool.h"
#include "base/trace_event/trace_event.h"
#include "components/viz/common/frame_sinks/copy_output_result.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -53,20 +55,24 @@ void CopyOutputRequest::SetUniformScaleRatio(int scale_from, int scale_to) {
}
void CopyOutputRequest::SendResult(std::unique_ptr<CopyOutputResult> result) {
- TRACE_EVENT_NESTABLE_ASYNC_END1("viz", "CopyOutputRequest", this, "success",
- !result->IsEmpty());
- if (result_task_runner_) {
- result_task_runner_->PostTask(
- FROM_HERE,
- base::BindOnce(std::move(result_callback_), std::move(result)));
- result_task_runner_ = nullptr;
- } else {
- std::move(result_callback_).Run(std::move(result));
- }
+ TRACE_EVENT_NESTABLE_ASYNC_END2(
+ "viz", "CopyOutputRequest", this, "success", !result->IsEmpty(),
+ "has_provided_task_runner", !!result_task_runner_);
+ // Serializing the result requires an expensive copy, so to not block the
+ // any important thread we PostTask onto the threadpool by default, but if the
+ // user has provided a task runner use that instead.
+ auto runner =
+ result_task_runner_
+ ? result_task_runner_
+ : base::ThreadPool::CreateSequencedTaskRunner({base::MayBlock()});
+ runner->PostTask(FROM_HERE, base::BindOnce(std::move(result_callback_),
+ std::move(result)));
+ // Remove the reference to the task runner (no-op if we didn't have one).
+ result_task_runner_ = nullptr;
}
bool CopyOutputRequest::SendsResultsInCurrentSequence() const {
- return !result_task_runner_ ||
+ return result_task_runner_ &&
result_task_runner_->RunsTasksInCurrentSequence();
}