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

Side by Side Diff: sky/shell/ui/engine.cc

Issue 1220353002: Add padding values to View.idl (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « sky/shell/ui/engine.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "sky/shell/ui/engine.h" 5 #include "sky/shell/ui/engine.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/threading/worker_pool.h" 9 #include "base/threading/worker_pool.h"
10 #include "base/trace_event/trace_event.h" 10 #include "base/trace_event/trace_event.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 51
52 Engine::Config::Config() { 52 Engine::Config::Config() {
53 } 53 }
54 54
55 Engine::Config::~Config() { 55 Engine::Config::~Config() {
56 } 56 }
57 57
58 Engine::Engine(const Config& config) 58 Engine::Engine(const Config& config)
59 : config_(config), 59 : config_(config),
60 animator_(new Animator(config, this)), 60 animator_(new Animator(config, this)),
61 device_pixel_ratio_(1.0f),
62 binding_(this), 61 binding_(this),
63 weak_factory_(this) { 62 weak_factory_(this) {
64 } 63 }
65 64
66 Engine::~Engine() { 65 Engine::~Engine() {
67 } 66 }
68 67
69 base::WeakPtr<Engine> Engine::GetWeakPtr() { 68 base::WeakPtr<Engine> Engine::GetWeakPtr() {
70 return weak_factory_.GetWeakPtr(); 69 return weak_factory_.GetWeakPtr();
71 } 70 }
(...skipping 23 matching lines...) Expand all
95 94
96 SkRTreeFactory factory; 95 SkRTreeFactory factory;
97 SkPictureRecorder recorder; 96 SkPictureRecorder recorder;
98 auto canvas = skia::SharePtr(recorder.beginRecording( 97 auto canvas = skia::SharePtr(recorder.beginRecording(
99 physical_size_.width(), physical_size_.height(), &factory, 98 physical_size_.width(), physical_size_.height(), &factory,
100 SkPictureRecorder::kComputeSaveLayerInfo_RecordFlag)); 99 SkPictureRecorder::kComputeSaveLayerInfo_RecordFlag));
101 100
102 if (sky_view_) { 101 if (sky_view_) {
103 skia::RefPtr<SkPicture> picture = sky_view_->Paint(); 102 skia::RefPtr<SkPicture> picture = sky_view_->Paint();
104 canvas->clear(SK_ColorBLACK); 103 canvas->clear(SK_ColorBLACK);
105 canvas->scale(device_pixel_ratio_, device_pixel_ratio_); 104 canvas->scale(display_metrics_.device_pixel_ratio,
105 display_metrics_.device_pixel_ratio);
106 if (picture) 106 if (picture)
107 canvas->drawPicture(picture.get()); 107 canvas->drawPicture(picture.get());
108 } 108 }
109 109
110 return skia::AdoptRef(recorder.endRecordingAsPicture()); 110 return skia::AdoptRef(recorder.endRecordingAsPicture());
111 } 111 }
112 112
113 void Engine::ConnectToEngine(mojo::InterfaceRequest<SkyEngine> request) { 113 void Engine::ConnectToEngine(mojo::InterfaceRequest<SkyEngine> request) {
114 binding_.Bind(request.Pass()); 114 binding_.Bind(request.Pass());
115 } 115 }
116 116
117 void Engine::OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget) { 117 void Engine::OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget) {
118 config_.gpu_task_runner->PostTask( 118 config_.gpu_task_runner->PostTask(
119 FROM_HERE, base::Bind(&GPUDelegate::OnAcceleratedWidgetAvailable, 119 FROM_HERE, base::Bind(&GPUDelegate::OnAcceleratedWidgetAvailable,
120 config_.gpu_delegate, widget)); 120 config_.gpu_delegate, widget));
121 if (sky_view_) 121 if (sky_view_)
122 ScheduleFrame(); 122 ScheduleFrame();
123 } 123 }
124 124
125 void Engine::OnOutputSurfaceDestroyed() { 125 void Engine::OnOutputSurfaceDestroyed() {
126 config_.gpu_task_runner->PostTask( 126 config_.gpu_task_runner->PostTask(
127 FROM_HERE, 127 FROM_HERE,
128 base::Bind(&GPUDelegate::OnOutputSurfaceDestroyed, config_.gpu_delegate)); 128 base::Bind(&GPUDelegate::OnOutputSurfaceDestroyed, config_.gpu_delegate));
129 } 129 }
130 130
131 void Engine::OnViewportMetricsChanged(int width, int height, 131 void Engine::OnViewportMetricsChanged(ViewportMetricsPtr metrics) {
132 float device_pixel_ratio) { 132 physical_size_.SetSize(metrics->physical_width, metrics->physical_height);
133 physical_size_.SetSize(width, height); 133
134 device_pixel_ratio_ = device_pixel_ratio; 134 display_metrics_.physical_size = physical_size_;
135 display_metrics_.device_pixel_ratio = metrics->device_pixel_ratio;
136 display_metrics_.padding_top = metrics->padding_top;
137 display_metrics_.padding_right = metrics->padding_right;
138 display_metrics_.padding_bottom = metrics->padding_bottom;
139 display_metrics_.padding_left = metrics->padding_left;
135 140
136 if (sky_view_) 141 if (sky_view_)
137 UpdateSkyViewSize(); 142 sky_view_->SetDisplayMetrics(display_metrics_);
138 }
139
140 void Engine::UpdateSkyViewSize() {
141 CHECK(sky_view_);
142 blink::SkyDisplayMetrics metrics;
143 metrics.physical_size = physical_size_;
144 metrics.device_pixel_ratio = device_pixel_ratio_;
145 sky_view_->SetDisplayMetrics(metrics);
146 } 143 }
147 144
148 void Engine::OnInputEvent(InputEventPtr event) { 145 void Engine::OnInputEvent(InputEventPtr event) {
149 TRACE_EVENT0("sky", "Engine::OnInputEvent"); 146 TRACE_EVENT0("sky", "Engine::OnInputEvent");
150 scoped_ptr<blink::WebInputEvent> web_event = 147 scoped_ptr<blink::WebInputEvent> web_event =
151 ConvertEvent(event, device_pixel_ratio_); 148 ConvertEvent(event, display_metrics_.device_pixel_ratio);
152 if (!web_event) 149 if (!web_event)
153 return; 150 return;
154 if (sky_view_) 151 if (sky_view_)
155 sky_view_->HandleInputEvent(*web_event); 152 sky_view_->HandleInputEvent(*web_event);
156 } 153 }
157 154
158 void Engine::RunFromLibrary(const std::string& name) { 155 void Engine::RunFromLibrary(const std::string& name) {
159 sky_view_ = blink::SkyView::Create(this); 156 sky_view_ = blink::SkyView::Create(this);
160 sky_view_->RunFromLibrary(blink::WebString::fromUTF8(name), 157 sky_view_->RunFromLibrary(blink::WebString::fromUTF8(name),
161 dart_library_provider_.get()); 158 dart_library_provider_.get());
162 UpdateSkyViewSize(); 159 sky_view_->SetDisplayMetrics(display_metrics_);
163 } 160 }
164 161
165 void Engine::RunFromSnapshotStream( 162 void Engine::RunFromSnapshotStream(
166 const std::string& name, 163 const std::string& name,
167 mojo::ScopedDataPipeConsumerHandle snapshot) { 164 mojo::ScopedDataPipeConsumerHandle snapshot) {
168 sky_view_ = blink::SkyView::Create(this); 165 sky_view_ = blink::SkyView::Create(this);
169 sky_view_->RunFromSnapshot(blink::WebString::fromUTF8(name), snapshot.Pass()); 166 sky_view_->RunFromSnapshot(blink::WebString::fromUTF8(name), snapshot.Pass());
170 UpdateSkyViewSize(); 167 sky_view_->SetDisplayMetrics(display_metrics_);
171 } 168 }
172 169
173 void Engine::RunFromNetwork(const mojo::String& url) { 170 void Engine::RunFromNetwork(const mojo::String& url) {
174 dart_library_provider_.reset( 171 dart_library_provider_.reset(
175 new DartLibraryProviderNetwork(g_platform_impl->networkService())); 172 new DartLibraryProviderNetwork(g_platform_impl->networkService()));
176 RunFromLibrary(url); 173 RunFromLibrary(url);
177 } 174 }
178 175
179 void Engine::RunFromFile(const mojo::String& main, 176 void Engine::RunFromFile(const mojo::String& main,
180 const mojo::String& package_root) { 177 const mojo::String& package_root) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 219
223 void Engine::DidNavigateLocally(const mojo::String& url) { 220 void Engine::DidNavigateLocally(const mojo::String& url) {
224 } 221 }
225 222
226 void Engine::RequestNavigateHistory(int32_t delta) { 223 void Engine::RequestNavigateHistory(int32_t delta) {
227 NOTIMPLEMENTED(); 224 NOTIMPLEMENTED();
228 } 225 }
229 226
230 } // namespace shell 227 } // namespace shell
231 } // namespace sky 228 } // namespace sky
OLDNEW
« no previous file with comments | « sky/shell/ui/engine.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698