Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Unified Diff: services/ui/demo/bitmap_uploader.cc

Issue 2440453002: Splitting the Mus demo code out of a service. (Closed)
Patch Set: Rebased Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: services/ui/demo/bitmap_uploader.cc
diff --git a/services/ui/demo/bitmap_uploader.cc b/services/ui/demo/bitmap_uploader.cc
index c6653e1090a5860c5fe8b7c4c6668926f63d758e..51664be84f409e8d327d854d0e755da7a0263f6f 100644
--- a/services/ui/demo/bitmap_uploader.cc
+++ b/services/ui/demo/bitmap_uploader.cc
@@ -35,17 +35,16 @@ BitmapUploader::BitmapUploader(Window* window)
width_(0),
height_(0),
format_(BGRA),
- next_resource_id_(1u) {
-}
+ next_resource_id_(1u),
+ weak_factory_(this) {}
void BitmapUploader::Init(ui::GpuService* gpu_service) {
surface_ = window_->RequestSurface(mojom::SurfaceType::DEFAULT);
surface_->BindToThread();
surface_->set_client(this);
- gles2_context_ = GLES2Context::CreateOffscreenContext(
- gpu_service->EstablishGpuChannelSync(),
- base::ThreadTaskRunnerHandle::Get());
+ gpu_service->EstablishGpuChannel(base::Bind(
+ &BitmapUploader::OnGpuChannelEstablished, weak_factory_.GetWeakPtr()));
}
BitmapUploader::~BitmapUploader() {}
@@ -174,6 +173,12 @@ void BitmapUploader::Upload() {
surface_->SubmitCompositorFrame(std::move(frame), base::Closure());
}
+void BitmapUploader::OnGpuChannelEstablished(
+ scoped_refptr<gpu::GpuChannelHost> gpu_channel) {
+ gles2_context_ = GLES2Context::CreateOffscreenContext(
+ gpu_channel, base::ThreadTaskRunnerHandle::Get());
+}
+
uint32_t BitmapUploader::BindTextureForSize(const gfx::Size& size) {
gpu::gles2::GLES2Interface* gl = gles2_context_->interface();
// TODO(jamesr): Recycle textures.

Powered by Google App Engine
This is Rietveld 408576698