gargerak / gargerak2

0 stars 0 forks source link

final #4

Open gargerak opened 1 year ago

gargerak commented 1 year ago

/ Copyright 2019 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file.

include "android_webview/browser/gfx/task_queue_webview.h"

include

include

include "android_webview/common/aw_features.h"

include "base/auto_reset.h"

include "base/containers/queue.h"

include "base/functional/bind.h"

include "base/logging.h"

include "base/synchronization/condition_variable.h"

include "base/synchronization/lock.h"

include "base/task/single_thread_task_runner.h"

include "base/thread_annotations.h"

include "base/threading/thread_checker.h"

include "base/threading/thread_local.h"

include "base/trace_event/trace_event.h"

include "components/viz/common/features.h"

namespace android_webview { namespace { // The client is the single viz thread and the gpu service runs on the render // thread. Render thread is allowed to block on the viz thread, but not the // other way around. This achieves viz scheduling tasks to gpu by first blocking // render thread on the viz thread so render thread is ready to receive and run // tasks. // // Lifetime: Singleton class TaskQueueViz : public TaskQueueWebView { public: TaskQueueViz(); TaskQueueViz(const TaskQueueViz&) = delete; TaskQueueViz& operator=(const TaskQueueViz&) = delete; ~TaskQueueViz() override; // TaskQueueWebView overrides. void ScheduleTask(base::OnceClosure task, bool out_of_order) override; void ScheduleOrRetainTask(base::OnceClosure task) override; void ScheduleIdleTask(base::OnceClosure task) override; scoped_refptr GetClientTaskRunner() override; void InitializeVizThread(const scoped_refptr& viz_task_runner) override; void ScheduleOnVizAndBlock(VizTask viz_task) override; void ResetRenderThreadForTesting() override { DETACH_FROM_THREAD(render_threadchecker); }

private: void RunOnViz(VizTask viz_task); 3 changes: 3 additions & 0 deletions 3
android_webview/browser/gfx/task_queue_webview.h

@@ -43,6 +43,9 @@ class TaskQueueWebView { // Used to post task to client thread. virtual scoped_refptr GetClientTaskRunner() = 0;

// Uniti tests can switch render thread. virtual void ResetRenderThreadForTesting() = 0;

protected: virtual ~TaskQueueWebView() = default; }; 3 changes: 3 additions & 0 deletions 3
android_webview/browser/gfx/test/invalidate_test.cc

@@ -9,6 +9,7 @@

include "android_webview/browser/gfx/root_frame_sink.h"

include "android_webview/browser/gfx/root_frame_sink_proxy.h"

include "android_webview/browser/gfx/scoped_app_gl_state_restore.h"

include "android_webview/browser/gfx/task_queue_webview.h"

include "android_webview/browser/gfx/viz_compositor_thread_runner_webview.h"

include "base/notreached.h"

include "base/task/single_thread_task_runner.h"

@@ -274,6 +275,7 @@ class InvalidateTest public: InvalidateTest() : taskenvironment(std::make_unique()) { TaskQueueWebView::GetInstance()->ResetRenderThreadForTesting(); begin_framesource = std::make_unique(this); root_frame_sinkproxy = std::makeunique( base::SingleThreadTaskRunner::GetCurrentDefault(), this, @@ -309,6 +311,7 @@ class InvalidateTest }, std::move(client))); render_threadmanager->DestroyHardwareRendererOnRT(false, false); TaskQueueWebView::GetInstance()->ResetRenderThreadForTesting(); }

// viz::ExternalBeginFrameSourceClient