未验证 提交 9d711ccf 编写于 作者: S Sigurd Meldgaard 提交者: GitHub

Move texture registry to platform view (#4388)

* Move texture registry ownership to platform view

This enables the texture registry to survive activity pause on Android.

* Remove debug info

* Formatted

* Set texture registry on initial rasterizer

* Remove unneccessary std::move
上级 1e6ebb35
......@@ -58,11 +58,11 @@ CompositorContext::ScopedFrame::~ScopedFrame() {
}
void CompositorContext::OnGrContextCreated() {
texture_registry_.OnGrContextCreated();
texture_registry_->OnGrContextCreated();
}
void CompositorContext::OnGrContextDestroyed() {
texture_registry_.OnGrContextDestroyed();
texture_registry_->OnGrContextDestroyed();
raster_cache_.Clear();
}
......
......@@ -62,7 +62,7 @@ class CompositorContext {
RasterCache& raster_cache() { return raster_cache_; }
TextureRegistry& texture_registry() { return texture_registry_; }
TextureRegistry& texture_registry() { return *texture_registry_; }
const Counter& frame_count() const { return frame_count_; }
......@@ -72,9 +72,13 @@ class CompositorContext {
const CounterValues& memory_usage() const { return memory_usage_; }
void SetTextureRegistry(TextureRegistry* textureRegistry) {
texture_registry_ = textureRegistry;
}
private:
RasterCache raster_cache_;
TextureRegistry texture_registry_;
TextureRegistry* texture_registry_;
std::unique_ptr<ProcessInfo> process_info_;
Counter frame_count_;
Stopwatch frame_time_;
......
......@@ -38,7 +38,7 @@ void NullRasterizer::DrawLastLayerTree() {
}
flow::TextureRegistry& NullRasterizer::GetTextureRegistry() {
return texture_registry_;
return *texture_registry_;
}
void NullRasterizer::Clear(SkColor color, const SkISize& size) {
......@@ -59,4 +59,9 @@ void NullRasterizer::AddNextFrameCallback(fxl::Closure nextFrameCallback) {
// Null rasterizer. Nothing to do.
}
void NullRasterizer::SetTextureRegistry(
flow::TextureRegistry* textureRegistry) {
texture_registry_ = textureRegistry;
}
} // namespace shell
......@@ -36,10 +36,12 @@ class NullRasterizer : public Rasterizer {
void AddNextFrameCallback(fxl::Closure nextFrameCallback) override;
void SetTextureRegistry(flow::TextureRegistry* textureRegistry) override;
private:
std::unique_ptr<Surface> surface_;
fml::WeakPtrFactory<NullRasterizer> weak_factory_;
flow::TextureRegistry texture_registry_;
flow::TextureRegistry* texture_registry_;
FXL_DISALLOW_COPY_AND_ASSIGN(NullRasterizer);
};
......
......@@ -18,6 +18,7 @@ namespace shell {
PlatformView::PlatformView(std::unique_ptr<Rasterizer> rasterizer)
: rasterizer_(std::move(rasterizer)), size_(SkISize::Make(0, 0)) {
rasterizer_->SetTextureRegistry(&texture_registry_);
Shell::Shared().AddPlatformView(this);
}
......@@ -35,6 +36,7 @@ void PlatformView::SetRasterizer(std::unique_ptr<Rasterizer> rasterizer) {
Rasterizer* r = rasterizer_.release();
blink::Threads::Gpu()->PostTask([r]() { delete r; });
rasterizer_ = std::move(rasterizer);
rasterizer_->SetTextureRegistry(&texture_registry_);
engine_->set_rasterizer(rasterizer_->GetWeakRasterizerPtr());
}
......
......@@ -90,6 +90,7 @@ class PlatformView : public std::enable_shared_from_this<PlatformView> {
SurfaceConfig surface_config_;
std::unique_ptr<Rasterizer> rasterizer_;
flow::TextureRegistry texture_registry_;
std::unique_ptr<Engine> engine_;
std::unique_ptr<VsyncWaiter> vsync_waiter_;
SkISize size_;
......
......@@ -42,6 +42,8 @@ class Rasterizer {
// Set a callback to be called once when the next frame is drawn.
virtual void AddNextFrameCallback(fxl::Closure nextFrameCallback) = 0;
virtual void SetTextureRegistry(flow::TextureRegistry* textureRegistry) = 0;
};
} // namespace shell
......
......@@ -161,4 +161,8 @@ void GPURasterizer::NotifyNextFrameOnce() {
}
}
void GPURasterizer::SetTextureRegistry(flow::TextureRegistry* textureRegistry) {
compositor_context_.SetTextureRegistry(textureRegistry);
}
} // namespace shell
......@@ -42,6 +42,8 @@ class GPURasterizer : public Rasterizer {
// Set a callback to be called once when the next frame is drawn.
void AddNextFrameCallback(fxl::Closure nextFrameCallback) override;
void SetTextureRegistry(flow::TextureRegistry* textureRegistry) override;
private:
std::unique_ptr<Surface> surface_;
flow::CompositorContext compositor_context_;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册