-
Notifications
You must be signed in to change notification settings - Fork 2
[Impeller] Use the IO context for OpenGL program setup #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: flutter-3.41.9
Are you sure you want to change the base?
Changes from all commits
1ab4750
f4efdc4
1986ea4
95d6d8b
efbbef4
9d6b92a
0f55c1e
a6b3245
91820f3
5c339ba
1755b06
84cbe84
edc184c
13d3be6
1765732
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| // Copyright 2013 The Flutter 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 "impeller/renderer/backend/gles/pipeline_compile_queue_gles.h" | ||
|
|
||
| #include "flutter/fml/logging.h" | ||
| #include "flutter/fml/trace_event.h" | ||
|
|
||
| namespace impeller { | ||
|
|
||
| std::shared_ptr<PipelineCompileQueueGLES> PipelineCompileQueueGLES::Create( | ||
| fml::RefPtr<fml::TaskRunner> worker_task_runner) { | ||
| return std::shared_ptr<PipelineCompileQueueGLES>( | ||
| new PipelineCompileQueueGLES(std::move(worker_task_runner))); | ||
| } | ||
|
|
||
| PipelineCompileQueueGLES::PipelineCompileQueueGLES( | ||
| fml::RefPtr<fml::TaskRunner> worker_task_runner) | ||
| : worker_task_runner_(std::move(worker_task_runner)) {} | ||
|
|
||
| PipelineCompileQueueGLES::~PipelineCompileQueueGLES() = default; | ||
|
|
||
| void PipelineCompileQueueGLES::OnJobAdded() { | ||
| Lock lock(processing_mutex_); | ||
| if (!is_processing_) { | ||
| is_processing_ = true; | ||
| ProcessJobsSequentially(); | ||
| } | ||
| } | ||
|
|
||
| void PipelineCompileQueueGLES::PostJob(const fml::closure& job) { | ||
| if (!job) { | ||
| return; | ||
| } | ||
| if (worker_task_runner_) { | ||
| worker_task_runner_->PostTask(job); | ||
| } else { | ||
| // No task runner available, execute synchronously on the current thread. | ||
| // This is safe in Playground/test environments where the current thread | ||
| // is the GL thread. | ||
| job(); | ||
| } | ||
| } | ||
|
|
||
| void PipelineCompileQueueGLES::ProcessJobsSequentially() { | ||
| PostJob([weak_queue = weak_from_this()]() { | ||
| if (auto queue = std::static_pointer_cast<PipelineCompileQueueGLES>( | ||
| weak_queue.lock())) { | ||
| queue->DoOneJob(); | ||
| { | ||
| Lock lock(queue->processing_mutex_); | ||
| if (!queue->HasPendingJobs()) { | ||
| queue->is_processing_ = false; | ||
| return; | ||
| } | ||
| } | ||
| queue->ProcessJobsSequentially(); | ||
| } | ||
| }); | ||
| } | ||
|
Comment on lines
+46
to
+61
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If void PipelineCompileQueueGLES::ProcessJobsSequentially() {
if (!worker_task_runner_) {
while (auto job = TakeNextJob()) {
job();
}
Lock lock(processing_mutex_);
is_processing_ = false;
return;
}
PostJob([weak_queue = weak_from_this()]() {
if (auto queue = std::static_pointer_cast<PipelineCompileQueueGLES>(
weak_queue.lock())) {
queue->DoOneJob();
{
Lock lock(queue->processing_mutex_);
if (!queue->HasPendingJobs()) {
queue->is_processing_ = false;
return;
}
}
queue->ProcessJobsSequentially();
}
});
}
Comment on lines
+46
to
+61
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The current implementation of |
||
|
|
||
| } // namespace impeller | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| // Copyright 2013 The Flutter 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 FLUTTER_IMPELLER_RENDERER_BACKEND_GLES_PIPELINE_COMPILE_QUEUE_GLES_H_ | ||
| #define FLUTTER_IMPELLER_RENDERER_BACKEND_GLES_PIPELINE_COMPILE_QUEUE_GLES_H_ | ||
|
|
||
| #include "flutter/fml/closure.h" | ||
| #include "flutter/fml/task_runner.h" | ||
| #include "impeller/base/thread.h" | ||
| #include "impeller/renderer/pipeline_compile_queue.h" | ||
|
|
||
| namespace impeller { | ||
|
|
||
| class PipelineCompileQueueGLES : public PipelineCompileQueue { | ||
| public: | ||
| static std::shared_ptr<PipelineCompileQueueGLES> Create( | ||
| fml::RefPtr<fml::TaskRunner> worker_task_runner); | ||
|
|
||
| explicit PipelineCompileQueueGLES( | ||
| fml::RefPtr<fml::TaskRunner> worker_task_runner); | ||
|
|
||
| ~PipelineCompileQueueGLES() override; | ||
|
|
||
| PipelineCompileQueueGLES(const PipelineCompileQueueGLES&) = delete; | ||
|
|
||
| PipelineCompileQueueGLES& operator=(const PipelineCompileQueueGLES&) = delete; | ||
|
|
||
| //---------------------------------------------------------------------------- | ||
| /// @brief Post a job to the worker task runner. | ||
| /// | ||
| /// @param[in] job The job | ||
| /// | ||
| void PostJob(const fml::closure& job) override; | ||
|
|
||
| //---------------------------------------------------------------------------- | ||
| /// @brief Called after a job has been added to the queue. Implements | ||
| /// the sequential scheduling strategy for GLES. | ||
| /// | ||
| void OnJobAdded() override; | ||
|
|
||
| private: | ||
| void ProcessJobsSequentially(); | ||
|
|
||
| fml::RefPtr<fml::TaskRunner> worker_task_runner_; | ||
| Mutex processing_mutex_; | ||
| bool is_processing_ IPLR_GUARDED_BY(processing_mutex_) = false; | ||
| }; | ||
|
|
||
| } // namespace impeller | ||
|
|
||
| #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_GLES_PIPELINE_COMPILE_QUEUE_GLES_H_ |
Uh oh!
There was an error while loading. Please reload this page.