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

Side by Side Diff: sky/examples/raw/launcher.dart

Issue 1190123003: Decouple Canvas from DisplayList and map Picture and PictureRecorder more directly to their Skia co… (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Rebased version of previous patch 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
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 import "dart:math"; 5 import "dart:math";
6 import 'dart:sky'; 6 import 'dart:sky';
7 7
8 import 'package:sky/framework/shell.dart' as shell; 8 import 'package:sky/framework/shell.dart' as shell;
9 import 'package:mojom/intents/intents.mojom.dart'; 9 import 'package:mojom/intents/intents.mojom.dart';
10 10
11 Picture draw(int a, int r, int g, int b) { 11 Picture draw(int a, int r, int g, int b) {
12 double width = view.width; 12 double width = view.width;
13 double height = view.height; 13 double height = view.height;
14 14
15 PictureRecorder recorder = new PictureRecorder(width, height); 15 PictureRecorder recorder = new PictureRecorder();
16 Canvas canvas = new Canvas(recorder, width, height);
16 double radius = min(width, height) * 0.45; 17 double radius = min(width, height) * 0.45;
17 18
18 Paint paint = new Paint()..color = new Color.fromARGB(a, r, g, b); 19 Paint paint = new Paint()..color = new Color.fromARGB(a, r, g, b);
19 recorder.drawRect(new Rect.fromSize(new Size(width, height)), paint); 20 canvas.drawRect(new Rect.fromSize(new Size(width, height)), paint);
20 return recorder.endRecording(); 21 return recorder.endRecording();
21 } 22 }
22 23
23 bool handleEvent(Event event) { 24 bool handleEvent(Event event) {
24 if (event.type == "pointerdown") { 25 if (event.type == "pointerdown") {
25 view.picture = draw(255, 0, 0, 255); 26 view.picture = draw(255, 0, 0, 255);
26 view.scheduleFrame(); 27 view.scheduleFrame();
27 return true; 28 return true;
28 } 29 }
29 30
(...skipping 18 matching lines...) Expand all
48 return false; 49 return false;
49 } 50 }
50 51
51 void main() { 52 void main() {
52 print("Hello, world"); 53 print("Hello, world");
53 view.picture = draw(255, 255, 255, 0); 54 view.picture = draw(255, 255, 255, 0);
54 view.scheduleFrame(); 55 view.scheduleFrame();
55 56
56 view.setEventCallback(handleEvent); 57 view.setEventCallback(handleEvent);
57 } 58 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698