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

Side by Side Diff: examples/ui/jank/jank.cc

Issue 2011713003: Roll skia to 8cc209111876b7c78b5ec577c9221d8ed5e21024 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 6 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 | « apps/moterm/moterm_view.cc ('k') | examples/ui/noodles/frame.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <unistd.h> 5 #include <unistd.h>
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 52
53 class JankView : public mojo::ui::GaneshView, 53 class JankView : public mojo::ui::GaneshView,
54 public mojo::ui::ChoreographerDelegate, 54 public mojo::ui::ChoreographerDelegate,
55 public mojo::ui::InputListener { 55 public mojo::ui::InputListener {
56 public: 56 public:
57 JankView(mojo::InterfaceHandle<mojo::ApplicationConnector> app_connector, 57 JankView(mojo::InterfaceHandle<mojo::ApplicationConnector> app_connector,
58 mojo::InterfaceRequest<mojo::ui::ViewOwner> view_owner_request) 58 mojo::InterfaceRequest<mojo::ui::ViewOwner> view_owner_request)
59 : GaneshView(app_connector.Pass(), view_owner_request.Pass(), "Jank"), 59 : GaneshView(app_connector.Pass(), view_owner_request.Pass(), "Jank"),
60 choreographer_(scene(), this), 60 choreographer_(scene(), this),
61 input_handler_(GetViewServiceProvider(), this), 61 input_handler_(GetViewServiceProvider(), this),
62 typeface_(skia::AdoptRef(SkTypeface::CreateFromStream( 62 typeface_(SkTypeface::MakeFromStream(
63 new SkMemoryStream(font_data::kDejaVuSansMonoRegular.data, 63 new SkMemoryStream(font_data::kDejaVuSansMonoRegular.data,
64 font_data::kDejaVuSansMonoRegular.size)))) {} 64 font_data::kDejaVuSansMonoRegular.size))) {}
65 65
66 ~JankView() override {} 66 ~JankView() override {}
67 67
68 private: 68 private:
69 // |GaneshView|: 69 // |GaneshView|:
70 void OnPropertiesChanged( 70 void OnPropertiesChanged(
71 uint32_t old_scene_version, 71 uint32_t old_scene_version,
72 mojo::ui::ViewPropertiesPtr old_properties) override { 72 mojo::ui::ViewPropertiesPtr old_properties) override {
73 choreographer_.ScheduleDraw(); 73 choreographer_.ScheduleDraw();
74 } 74 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 boxPaint.setColor(SkColorSetRGB(200, 200, 200)); 156 boxPaint.setColor(SkColorSetRGB(200, 200, 200));
157 canvas->drawRect(bounds, boxPaint); 157 canvas->drawRect(bounds, boxPaint);
158 boxPaint.setColor(SkColorSetRGB(40, 40, 40)); 158 boxPaint.setColor(SkColorSetRGB(40, 40, 40));
159 boxPaint.setStyle(SkPaint::kStroke_Style); 159 boxPaint.setStyle(SkPaint::kStroke_Style);
160 canvas->drawRect(bounds, boxPaint); 160 canvas->drawRect(bounds, boxPaint);
161 161
162 SkPaint textPaint; 162 SkPaint textPaint;
163 textPaint.setColor(SK_ColorBLACK); 163 textPaint.setColor(SK_ColorBLACK);
164 textPaint.setTextSize(16); 164 textPaint.setTextSize(16);
165 textPaint.setTextEncoding(SkPaint::kUTF8_TextEncoding); 165 textPaint.setTextEncoding(SkPaint::kUTF8_TextEncoding);
166 textPaint.setTypeface(typeface_.get()); 166 textPaint.setTypeface(typeface_);
167 textPaint.setAntiAlias(true); 167 textPaint.setAntiAlias(true);
168 SkRect textBounds; 168 SkRect textBounds;
169 textPaint.measureText(label, strlen(label), &textBounds); 169 textPaint.measureText(label, strlen(label), &textBounds);
170 canvas->drawText(label, strlen(label), 170 canvas->drawText(label, strlen(label),
171 bounds.centerX() - textBounds.centerX(), 171 bounds.centerX() - textBounds.centerX(),
172 bounds.centerY() - textBounds.centerY(), textPaint); 172 bounds.centerY() - textBounds.centerY(), textPaint);
173 } 173 }
174 174
175 void OnClick(const Button& button) { 175 void OnClick(const Button& button) {
176 LOG(INFO) << "Clicked: " << button.label; 176 LOG(INFO) << "Clicked: " << button.label;
(...skipping 11 matching lines...) Expand all
188 188
189 case Action::kCrash: { 189 case Action::kCrash: {
190 abort(); 190 abort();
191 break; 191 break;
192 } 192 }
193 } 193 }
194 } 194 }
195 195
196 mojo::ui::Choreographer choreographer_; 196 mojo::ui::Choreographer choreographer_;
197 mojo::ui::InputHandler input_handler_; 197 mojo::ui::InputHandler input_handler_;
198 skia::RefPtr<SkTypeface> typeface_; 198 sk_sp<SkTypeface> typeface_;
199 int64_t stutter_end_time_ = 0u; 199 int64_t stutter_end_time_ = 0u;
200 200
201 DISALLOW_COPY_AND_ASSIGN(JankView); 201 DISALLOW_COPY_AND_ASSIGN(JankView);
202 }; 202 };
203 203
204 class JankApp : public mojo::ui::ViewProviderApp { 204 class JankApp : public mojo::ui::ViewProviderApp {
205 public: 205 public:
206 JankApp() {} 206 JankApp() {}
207 ~JankApp() override {} 207 ~JankApp() override {}
208 208
209 void CreateView( 209 void CreateView(
210 const std::string& connection_url, 210 const std::string& connection_url,
211 mojo::InterfaceRequest<mojo::ui::ViewOwner> view_owner_request, 211 mojo::InterfaceRequest<mojo::ui::ViewOwner> view_owner_request,
212 mojo::InterfaceRequest<mojo::ServiceProvider> services) override { 212 mojo::InterfaceRequest<mojo::ServiceProvider> services) override {
213 new JankView(mojo::CreateApplicationConnector(app_impl()->shell()), 213 new JankView(mojo::CreateApplicationConnector(app_impl()->shell()),
214 view_owner_request.Pass()); 214 view_owner_request.Pass());
215 } 215 }
216 216
217 private: 217 private:
218 DISALLOW_COPY_AND_ASSIGN(JankApp); 218 DISALLOW_COPY_AND_ASSIGN(JankApp);
219 }; 219 };
220 220
221 } // namespace examples 221 } // namespace examples
222 222
223 MojoResult MojoMain(MojoHandle application_request) { 223 MojoResult MojoMain(MojoHandle application_request) {
224 mojo::ApplicationRunnerChromium runner(new examples::JankApp()); 224 mojo::ApplicationRunnerChromium runner(new examples::JankApp());
225 return runner.Run(application_request); 225 return runner.Run(application_request);
226 } 226 }
OLDNEW
« no previous file with comments | « apps/moterm/moterm_view.cc ('k') | examples/ui/noodles/frame.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698