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

Side by Side Diff: sky/sdk/lib/rendering/object.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: Rework the API a bit Created 5 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
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' as math; 5 import 'dart:math' as math;
6 import 'dart:sky' as sky; 6 import 'dart:sky' as sky;
7 import 'dart:sky' show Point, Size, Rect, Color, Paint, Path; 7 import 'dart:sky' show Point, Size, Rect, Color, Paint, Path;
8 8
9 import '../base/hit_test.dart'; 9 import '../base/hit_test.dart';
10 import '../base/node.dart'; 10 import '../base/node.dart';
11 import '../base/scheduler.dart' as scheduler; 11 import '../base/scheduler.dart' as scheduler;
12 12
13 export 'dart:sky' show Point, Size, Rect, Color, Paint, Path; 13 export 'dart:sky' show Point, Size, Rect, Color, Paint, Path;
14 export '../base/hit_test.dart' show HitTestTarget, HitTestEntry, HitTestResult; 14 export '../base/hit_test.dart' show HitTestTarget, HitTestEntry, HitTestResult;
15 15
16 16
17 class ParentData { 17 class ParentData {
18 void detach() { 18 void detach() {
19 detachSiblings(); 19 detachSiblings();
20 } 20 }
21 void detachSiblings() { } // workaround for lack of inter-class mixins in Dart 21 void detachSiblings() { } // workaround for lack of inter-class mixins in Dart
22 void merge(ParentData other) { 22 void merge(ParentData other) {
23 // override this in subclasses to merge in data from other into this 23 // override this in subclasses to merge in data from other into this
24 assert(other.runtimeType == this.runtimeType); 24 assert(other.runtimeType == this.runtimeType);
25 } 25 }
26 String toString() => '<none>'; 26 String toString() => '<none>';
27 } 27 }
28 28
29 const kLayoutDirections = 4; 29 class RenderPictureRecorder extends sky.PictureRecorder {
30 RenderCanvas beginRecording(double width, double height) {
31 sky.Canvas originalCanvas = super.beginRecording(width, height);
32 RenderCanvas realCanvas = new RenderCanvas(originalCanvas);
33 setCanvas(realCanvas);
abarth-chromium 2015/06/20 00:50:29 I see, you're using this to solve the dangling SkC
34 return realCanvas;
35 }
36 }
30 37
31 class RenderObjectDisplayList extends sky.PictureRecorder { 38 class RenderCanvas extends sky.Canvas {
32 RenderObjectDisplayList(double width, double height) : super(width, height); 39 RenderCanvas(sky.Canvas canvas) : super(canvas);
Hixie 2015/06/20 00:44:52 We probably want to avoid making two instances of
abarth-chromium 2015/06/20 00:50:29 I don't understand why we can't just pass a sky.Pi
40
33 void paintChild(RenderObject child, Point position) { 41 void paintChild(RenderObject child, Point position) {
34 translate(position.x, position.y); 42 translate(position.x, position.y);
35 child.paint(this); 43 child.paint(this);
36 translate(-position.x, -position.y); 44 translate(-position.x, -position.y);
37 } 45 }
38 } 46 }
39 47
40 abstract class RenderObject extends AbstractNode implements HitTestTarget { 48 abstract class RenderObject extends AbstractNode implements HitTestTarget {
41 49
42 // LAYOUT 50 // LAYOUT
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 }) { } 215 }) { }
208 216
209 217
210 // PAINTING 218 // PAINTING
211 219
212 static bool debugDoingPaint = false; 220 static bool debugDoingPaint = false;
213 void markNeedsPaint() { 221 void markNeedsPaint() {
214 assert(!debugDoingPaint); 222 assert(!debugDoingPaint);
215 scheduler.ensureVisualUpdate(); 223 scheduler.ensureVisualUpdate();
216 } 224 }
217 void paint(RenderObjectDisplayList canvas) { } 225 void paint(RenderCanvas canvas) { }
218 226
219 227
220 // EVENTS 228 // EVENTS
221 229
222 void handleEvent(sky.Event event, HitTestEntry entry) { 230 void handleEvent(sky.Event event, HitTestEntry entry) {
223 // override this if you have a client, to hand it to the client 231 // override this if you have a client, to hand it to the client
224 // override this if you want to do anything with the event 232 // override this if you want to do anything with the event
225 } 233 }
226 234
227 235
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 int count = 1; 493 int count = 1;
486 ChildType child = _firstChild; 494 ChildType child = _firstChild;
487 while (child != null) { 495 while (child != null) {
488 result += '${prefix}child ${count}: ${child.toString(prefix)}'; 496 result += '${prefix}child ${count}: ${child.toString(prefix)}';
489 count += 1; 497 count += 1;
490 child = child.parentData.nextSibling; 498 child = child.parentData.nextSibling;
491 } 499 }
492 return result; 500 return result;
493 } 501 }
494 } 502 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698