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

Unified Diff: components/pdf_viewer/pdf_viewer.cc

Issue 1281663002: Mandoline: Allow submitting CompositorFrames directly to mojo::Views (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 5 years, 4 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: components/pdf_viewer/pdf_viewer.cc
diff --git a/components/pdf_viewer/pdf_viewer.cc b/components/pdf_viewer/pdf_viewer.cc
index aba1f63cf49ff26491addaec2c0c377f41ff9ab5..f7e51ffe3d39a6b8ced971c1d93ae9bd85a28f0b 100644
--- a/components/pdf_viewer/pdf_viewer.cc
+++ b/components/pdf_viewer/pdf_viewer.cc
@@ -72,18 +72,7 @@ class BitmapUploader : public mojo::ResourceReturner {
}
void Init(mojo::Shell* shell) {
- mojo::ServiceProviderPtr surfaces_service_provider;
- mojo::URLRequestPtr request(mojo::URLRequest::New());
- request->url = mojo::String::From("mojo:view_manager");
- shell->ConnectToApplication(request.Pass(),
- mojo::GetProxy(&surfaces_service_provider),
- nullptr, nullptr);
- ConnectToService(surfaces_service_provider.get(), &surface_);
- surface_->GetIdNamespace(
- base::Bind(&BitmapUploader::SetIdNamespace, base::Unretained(this)));
- mojo::ResourceReturnerPtr returner_ptr;
- returner_binding_.Bind(GetProxy(&returner_ptr));
- surface_->SetResourceReturner(returner_ptr.Pass());
+ view_->RequestCompositorFrameReceiver(GetProxy(&receiver_));
rjkroege 2015/08/13 18:04:01 i don't like this name receiver_ for the interface
Fady Samuel 2015/08/17 21:11:11 Renamed to cc_frame_receiver_ as per offline conve
mojo::ServiceProviderPtr gpu_service_provider;
mojo::URLRequestPtr request2(mojo::URLRequest::New());
@@ -106,7 +95,7 @@ class BitmapUploader : public mojo::ResourceReturner {
if (color_ == color)
return;
color_ = color;
- if (surface_)
+ if (receiver_)
Upload();
}
@@ -124,44 +113,20 @@ class BitmapUploader : public mojo::ResourceReturner {
height_ = height;
bitmap_ = data.Pass();
format_ = format;
- if (surface_)
+ if (receiver_)
Upload();
}
private:
void Upload() {
- mojo::Size size;
- size.width = view_->bounds().width;
- size.height = view_->bounds().height;
- if (!size.width || !size.height) {
- view_->SetSurfaceId(mojo::SurfaceId::New());
- return;
- }
-
- if (id_namespace_ == 0u) // Can't generate a qualified ID yet.
- return;
-
- if (size != surface_size_) {
- if (local_id_ != 0u) {
- surface_->DestroySurface(local_id_);
- }
- local_id_++;
- surface_->CreateSurface(local_id_);
- surface_size_ = size;
- auto qualified_id = mojo::SurfaceId::New();
- qualified_id->id_namespace = id_namespace_;
- qualified_id->local = local_id_;
- view_->SetSurfaceId(qualified_id.Pass());
- }
-
- gfx::Rect bounds(size.width, size.height);
+ gfx::Rect bounds(view_->bounds().To<gfx::Rect>());
mojo::PassPtr pass = mojo::CreateDefaultPass(1, bounds);
mojo::CompositorFramePtr frame = mojo::CompositorFrame::New();
frame->resources.resize(0u);
pass->quads.resize(0u);
pass->shared_quad_states.push_back(
- mojo::CreateDefaultSQS(size.To<gfx::Size>()));
+ mojo::CreateDefaultSQS(bounds.size()));
MojoGLES2MakeCurrent(gles2_context_);
if (bitmap_.get()) {
@@ -205,19 +170,19 @@ class BitmapUploader : public mojo::ResourceReturner {
quad->material = mojo::MATERIAL_TEXTURE_CONTENT;
mojo::RectPtr rect = mojo::Rect::New();
- if (width_ <= size.width && height_ <= size.height) {
+ if (width_ <= bounds.width() && height_ <= bounds.height()) {
rect->width = width_;
rect->height = height_;
} else {
// The source bitmap is larger than the viewport. Resize it while
// maintaining the aspect ratio.
- float width_ratio = static_cast<float>(width_) / size.width;
- float height_ratio = static_cast<float>(height_) / size.height;
+ float width_ratio = static_cast<float>(width_) / bounds.width();
+ float height_ratio = static_cast<float>(height_) / bounds.height();
if (width_ratio > height_ratio) {
- rect->width = size.width;
+ rect->width = bounds.width();
rect->height = height_ / width_ratio;
} else {
- rect->height = size.height;
+ rect->height = bounds.height();
rect->width = width_ / height_ratio;
}
}
@@ -266,7 +231,7 @@ class BitmapUploader : public mojo::ResourceReturner {
frame->passes.push_back(pass.Pass());
- surface_->SubmitFrame(local_id_, frame.Pass(), mojo::Closure());
+ receiver_->SubmitFrame(frame.Pass(), mojo::Closure());
}
uint32_t BindTextureForSize(const mojo::Size size) {
@@ -315,6 +280,7 @@ class BitmapUploader : public mojo::ResourceReturner {
mojo::View* view_;
mojo::GpuPtr gpu_service_;
+ mojo::CompositorFrameReceiverPtr receiver_;
rjkroege 2015/08/13 18:04:01 compositing_service_ ?
Fady Samuel 2015/08/17 21:11:11 Renamed to cc_frame_receiver as per our conversati
MojoGLES2Context gles2_context_;
mojo::Size size_;
@@ -323,8 +289,6 @@ class BitmapUploader : public mojo::ResourceReturner {
int height_;
Format format_;
scoped_ptr<std::vector<unsigned char>> bitmap_;
- mojo::SurfacePtr surface_;
- mojo::Size surface_size_;
uint32_t next_resource_id_;
uint32_t id_namespace_;
uint32_t local_id_;

Powered by Google App Engine
This is Rietveld 408576698