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

Side by Side Diff: services/native_viewport/native_viewport_impl.cc

Issue 826423008: Use local ids for Surfaces APIs that can only apply to local surfaces (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "services/native_viewport/native_viewport_impl.h" 5 #include "services/native_viewport/native_viewport_impl.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 19 matching lines...) Expand all
30 30
31 } // namespace 31 } // namespace
32 32
33 NativeViewportImpl::NativeViewportImpl(mojo::ApplicationImpl* app, 33 NativeViewportImpl::NativeViewportImpl(mojo::ApplicationImpl* app,
34 bool is_headless) 34 bool is_headless)
35 : is_headless_(is_headless), 35 : is_headless_(is_headless),
36 widget_id_(0u), 36 widget_id_(0u),
37 metrics_(mojo::ViewportMetrics::New()), 37 metrics_(mojo::ViewportMetrics::New()),
38 waiting_for_event_ack_(false), 38 waiting_for_event_ack_(false),
39 weak_factory_(this) { 39 weak_factory_(this) {
40 app->ConnectToService("mojo:surfaces_service", &surfaces_service_); 40 app->ConnectToService("mojo:surfaces_service", &surface_);
41 // TODO(jamesr): Should be mojo_gpu_service 41 // TODO(jamesr): Should be mojo_gpu_service
42 app->ConnectToService("mojo:native_viewport_service", &gpu_service_); 42 app->ConnectToService("mojo:native_viewport_service", &gpu_service_);
43 } 43 }
44 44
45 NativeViewportImpl::~NativeViewportImpl() { 45 NativeViewportImpl::~NativeViewportImpl() {
46 // Destroy the NativeViewport early on as it may call us back during 46 // Destroy the NativeViewport early on as it may call us back during
47 // destruction and we want to be in a known state. 47 // destruction and we want to be in a known state.
48 platform_viewport_.reset(); 48 platform_viewport_.reset();
49 } 49 }
50 50
(...skipping 26 matching lines...) Expand all
77 platform_viewport_->SetBounds(gfx::Rect(size.To<gfx::Size>())); 77 platform_viewport_->SetBounds(gfx::Rect(size.To<gfx::Size>()));
78 } 78 }
79 79
80 void NativeViewportImpl::SubmittedFrame(mojo::SurfaceIdPtr child_surface_id) { 80 void NativeViewportImpl::SubmittedFrame(mojo::SurfaceIdPtr child_surface_id) {
81 if (child_surface_id_.is_null()) { 81 if (child_surface_id_.is_null()) {
82 // If this is the first indication that the client will use surfaces, 82 // If this is the first indication that the client will use surfaces,
83 // initialize that system. 83 // initialize that system.
84 // TODO(jamesr): When everything is converted to surfaces initialize this 84 // TODO(jamesr): When everything is converted to surfaces initialize this
85 // eagerly. 85 // eagerly.
86 viewport_surface_.reset(new ViewportSurface( 86 viewport_surface_.reset(new ViewportSurface(
87 surfaces_service_.get(), gpu_service_.get(), 87 surface_.Pass(), gpu_service_.get(), metrics_->size.To<gfx::Size>(),
88 metrics_->size.To<gfx::Size>(),
89 child_surface_id.To<cc::SurfaceId>())); 88 child_surface_id.To<cc::SurfaceId>()));
90 if (widget_id_) 89 if (widget_id_)
91 viewport_surface_->SetWidgetId(widget_id_); 90 viewport_surface_->SetWidgetId(widget_id_);
92 } 91 }
93 child_surface_id_ = child_surface_id.To<cc::SurfaceId>(); 92 child_surface_id_ = child_surface_id.To<cc::SurfaceId>();
94 if (viewport_surface_) 93 if (viewport_surface_)
95 viewport_surface_->SetChildId(child_surface_id_); 94 viewport_surface_->SetChildId(child_surface_id_);
96 } 95 }
97 96
98 void NativeViewportImpl::SetEventDispatcher( 97 void NativeViewportImpl::SetEventDispatcher(
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 waiting_for_event_ack_ = false; 159 waiting_for_event_ack_ = false;
161 } 160 }
162 161
163 void NativeViewportImpl::ProcessOnMetricsChanged() { 162 void NativeViewportImpl::ProcessOnMetricsChanged() {
164 client()->OnMetricsChanged(metrics_.Clone()); 163 client()->OnMetricsChanged(metrics_.Clone());
165 if (viewport_surface_) 164 if (viewport_surface_)
166 viewport_surface_->SetSize(metrics_->size.To<gfx::Size>()); 165 viewport_surface_->SetSize(metrics_->size.To<gfx::Size>());
167 } 166 }
168 167
169 } // namespace native_viewport 168 } // namespace native_viewport
OLDNEW
« no previous file with comments | « services/native_viewport/native_viewport_impl.h ('k') | services/native_viewport/viewport_surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698