Skip to content

Commit

Permalink
registerTexture on the same thread as copypixelbuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
林一一 committed Aug 1, 2019
1 parent 44f2f07 commit b352144
Showing 1 changed file with 19 additions and 28 deletions.
47 changes: 19 additions & 28 deletions shell/common/shell.cc
Original file line number Diff line number Diff line change
Expand Up @@ -706,29 +706,23 @@ void Shell::OnPlatformViewRegisterTexture(
FML_DCHECK(is_setup_);
FML_DCHECK(task_runners_.GetPlatformTaskRunner()->RunsTasksOnCurrentThread());

task_runners_.GetGPUTaskRunner()->PostTask(
[rasterizer = rasterizer_->GetWeakPtr(), texture] {
if (rasterizer) {
if (auto* registry = rasterizer->GetTextureRegistry()) {
registry->RegisterTexture(texture);
}
}
});
if (rasterizer_) {
if (auto* registry = rasterizer_->GetTextureRegistry()) {
registry->RegisterTexture(texture);
}
}
}

// |PlatformView::Delegate|
void Shell::OnPlatformViewUnregisterTexture(int64_t texture_id) {
FML_DCHECK(is_setup_);
FML_DCHECK(task_runners_.GetPlatformTaskRunner()->RunsTasksOnCurrentThread());

task_runners_.GetGPUTaskRunner()->PostTask(
[rasterizer = rasterizer_->GetWeakPtr(), texture_id]() {
if (rasterizer) {
if (auto* registry = rasterizer->GetTextureRegistry()) {
registry->UnregisterTexture(texture_id);
}
}
});
if (rasterizer_) {
if (auto* registry = rasterizer_->GetTextureRegistry()) {
registry->UnregisterTexture(texture_id);
}
}
}

// |PlatformView::Delegate|
Expand All @@ -737,22 +731,19 @@ void Shell::OnPlatformViewMarkTextureFrameAvailable(int64_t texture_id) {
FML_DCHECK(task_runners_.GetPlatformTaskRunner()->RunsTasksOnCurrentThread());

// Tell the rasterizer that one of its textures has a new frame available.
task_runners_.GetGPUTaskRunner()->PostTask(
[rasterizer = rasterizer_->GetWeakPtr(), texture_id]() {
auto* registry = rasterizer->GetTextureRegistry();
auto* registry = rasterizer_->GetTextureRegistry();

if (!registry) {
return;
}
if (!registry) {
return;
}

auto texture = registry->GetTexture(texture_id);
auto texture = registry->GetTexture(texture_id);

if (!texture) {
return;
}
if (!texture) {
return;
}

texture->MarkNewFrameAvailable();
});
texture->MarkNewFrameAvailable();

// Schedule a new frame without having to rebuild the layer tree.
task_runners_.GetUITaskRunner()->PostTask([engine = engine_->GetWeakPtr()]() {
Expand Down

0 comments on commit b352144

Please sign in to comment.