gargerak / gargerak2

0 stars 0 forks source link

4/12 #3

Open gargerak opened 1 year ago

gargerak commented 1 year ago

bank mellat www.bsi24.ir https://ebanking.bsi24.ir

/ 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 <memory>
#include <utility>
#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<base::TaskRunner> GetClientTaskRunner() override;
  void InitializeVizThread(const scoped_refptr<base::SingleThreadTaskRunner>&
                               viz_task_runner) override;
  void ScheduleOnVizAndBlock(VizTask viz_task) override;
  void ResetRenderThreadForTesting() override {
    DETACH_FROM_THREAD(render_thread_checker_);
  }

 private:
  void RunOnViz(VizTask viz_task);
  3 changes: 3 additions & 0 deletions 3  
[android_webview/browser/gfx/task_queue_webview.h](https://github.com/gargerak/gargerak2/issues/3#diff-22d2815fc9ab54fd3c40b9d742bf3fc1e28237aca48c3dcfc6751a7e8e03497c)

@@ -43,6 +43,9 @@ class TaskQueueWebView {
  // Used to post task to client thread.
  virtual scoped_refptr<base::TaskRunner> 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](https://github.com/gargerak/gargerak2/issues/3#diff-3e07630c44d7327ac22c149281a926b9e3d5b102c820f39bb83f17c0f3e8cf37)

@@ -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()
      : task_environment_(std::make_unique<base::test::TaskEnvironment>()) {
    TaskQueueWebView::GetInstance()->ResetRenderThreadForTesting();
    begin_frame_source_ = std::make_unique<viz::ExternalBeginFrameSource>(this);
    root_frame_sink_proxy_ = std::make_unique<RootFrameSinkProxy>(
        base::SingleThreadTaskRunner::GetCurrentDefault(), this,
@@ -309,6 +311,7 @@ class InvalidateTest
                       },
                       std::move(client_)));
    render_thread_manager_->DestroyHardwareRendererOnRT(false, false);
    TaskQueueWebView::GetInstance()->ResetRenderThreadForTesting();
  }

  // viz::ExternalBeginFrameSourceClient