Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit e58764f

Browse files
authoredNov 22, 2017
Move texture registry ownership to platform view (#4348)
* Move texture registry ownership to platform view This enables the texture registry to survive activity pause on Android.
1 parent fbd3843 commit e58764f

9 files changed

+27
-6
lines changed
 

‎flow/compositor_context.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ CompositorContext::ScopedFrame::~ScopedFrame() {
5858
}
5959

6060
void CompositorContext::OnGrContextCreated() {
61-
texture_registry_.OnGrContextCreated();
61+
texture_registry_->OnGrContextCreated();
6262
}
6363

6464
void CompositorContext::OnGrContextDestroyed() {
65-
texture_registry_.OnGrContextDestroyed();
65+
texture_registry_->OnGrContextDestroyed();
6666
raster_cache_.Clear();
6767
}
6868

‎flow/compositor_context.h

+6-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class CompositorContext {
6262

6363
RasterCache& raster_cache() { return raster_cache_; }
6464

65-
TextureRegistry& texture_registry() { return texture_registry_; }
65+
TextureRegistry& texture_registry() { return *texture_registry_; }
6666

6767
const Counter& frame_count() const { return frame_count_; }
6868

@@ -72,9 +72,13 @@ class CompositorContext {
7272

7373
const CounterValues& memory_usage() const { return memory_usage_; }
7474

75+
void SetTextureRegistry(TextureRegistry* textureRegistry) {
76+
texture_registry_ = textureRegistry;
77+
}
78+
7579
private:
7680
RasterCache raster_cache_;
77-
TextureRegistry texture_registry_;
81+
TextureRegistry* texture_registry_;
7882
std::unique_ptr<ProcessInfo> process_info_;
7983
Counter frame_count_;
8084
Stopwatch frame_time_;

‎shell/common/null_rasterizer.cc

+6-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ void NullRasterizer::DrawLastLayerTree() {
3838
}
3939

4040
flow::TextureRegistry& NullRasterizer::GetTextureRegistry() {
41-
return texture_registry_;
41+
return *texture_registry_;
4242
}
4343

4444
void NullRasterizer::Clear(SkColor color, const SkISize& size) {
@@ -59,4 +59,9 @@ void NullRasterizer::AddNextFrameCallback(fxl::Closure nextFrameCallback) {
5959
// Null rasterizer. Nothing to do.
6060
}
6161

62+
void NullRasterizer::SetTextureRegistry(
63+
flow::TextureRegistry* textureRegistry) {
64+
texture_registry_ = textureRegistry;
65+
}
66+
6267
} // namespace shell

‎shell/common/null_rasterizer.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,12 @@ class NullRasterizer : public Rasterizer {
3636

3737
void AddNextFrameCallback(fxl::Closure nextFrameCallback) override;
3838

39+
void SetTextureRegistry(flow::TextureRegistry* textureRegistry) override;
40+
3941
private:
4042
std::unique_ptr<Surface> surface_;
4143
fml::WeakPtrFactory<NullRasterizer> weak_factory_;
42-
flow::TextureRegistry texture_registry_;
44+
flow::TextureRegistry* texture_registry_;
4345

4446
FXL_DISALLOW_COPY_AND_ASSIGN(NullRasterizer);
4547
};

‎shell/common/platform_view.cc

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ void PlatformView::SetRasterizer(std::unique_ptr<Rasterizer> rasterizer) {
3535
Rasterizer* r = rasterizer_.release();
3636
blink::Threads::Gpu()->PostTask([r]() { delete r; });
3737
rasterizer_ = std::move(rasterizer);
38+
rasterizer_->SetTextureRegistry(&texture_registry_);
3839
engine_->set_rasterizer(rasterizer_->GetWeakRasterizerPtr());
3940
}
4041

‎shell/common/platform_view.h

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ class PlatformView : public std::enable_shared_from_this<PlatformView> {
9090

9191
SurfaceConfig surface_config_;
9292
std::unique_ptr<Rasterizer> rasterizer_;
93+
flow::TextureRegistry texture_registry_;
9394
std::unique_ptr<Engine> engine_;
9495
std::unique_ptr<VsyncWaiter> vsync_waiter_;
9596
SkISize size_;

‎shell/common/rasterizer.h

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ class Rasterizer {
4242

4343
// Set a callback to be called once when the next frame is drawn.
4444
virtual void AddNextFrameCallback(fxl::Closure nextFrameCallback) = 0;
45+
46+
virtual void SetTextureRegistry(flow::TextureRegistry* textureRegistry) = 0;
4547
};
4648

4749
} // namespace shell

‎shell/gpu/gpu_rasterizer.cc

+4
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,8 @@ void GPURasterizer::NotifyNextFrameOnce() {
161161
}
162162
}
163163

164+
void GPURasterizer::SetTextureRegistry(flow::TextureRegistry* textureRegistry) {
165+
compositor_context_.SetTextureRegistry(std::move(textureRegistry));
166+
}
167+
164168
} // namespace shell

‎shell/gpu/gpu_rasterizer.h

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ class GPURasterizer : public Rasterizer {
4242
// Set a callback to be called once when the next frame is drawn.
4343
void AddNextFrameCallback(fxl::Closure nextFrameCallback) override;
4444

45+
void SetTextureRegistry(flow::TextureRegistry* textureRegistry) override;
46+
4547
private:
4648
std::unique_ptr<Surface> surface_;
4749
flow::CompositorContext compositor_context_;

0 commit comments

Comments
 (0)
This repository has been archived.