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

Side by Side Diff: sky/sdk/lib/rendering/box.dart

Issue 1216833003: Make rendering use PaintingNodes for increased efficiency. (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
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 7
8 import 'package:vector_math/vector_math.dart'; 8 import 'package:vector_math/vector_math.dart';
9 9
10 import '../base/debug.dart'; 10 import '../base/debug.dart';
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 assert(RenderObject.debugDoingLayout); 422 assert(RenderObject.debugDoingLayout);
423 assert((sizedByParent && debugDoingThisResize) || 423 assert((sizedByParent && debugDoingThisResize) ||
424 (!sizedByParent && debugDoingThisLayout)); 424 (!sizedByParent && debugDoingThisLayout));
425 if (value is _DebugSize) { 425 if (value is _DebugSize) {
426 assert(value._canBeUsedByParent); 426 assert(value._canBeUsedByParent);
427 assert(value._owner.parent == this); 427 assert(value._owner.parent == this);
428 } 428 }
429 _size = inDebugBuild ? new _DebugSize(value, this, debugCanParentUseSize) : value; 429 _size = inDebugBuild ? new _DebugSize(value, this, debugCanParentUseSize) : value;
430 } 430 }
431 431
432 Rect get paintBounds => Point.origin & size;
433
432 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings( prefix)}${prefix}size: ${size}\n'; 434 String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings( prefix)}${prefix}size: ${size}\n';
433 } 435 }
434 436
435 class RenderProxyBox extends RenderBox with RenderObjectWithChildMixin<RenderBox > { 437 class RenderProxyBox extends RenderBox with RenderObjectWithChildMixin<RenderBox > {
436 438
437 // ProxyBox assumes the child will be at 0,0 and will have the same size 439 // ProxyBox assumes the child will be at 0,0 and will have the same size
438 440
439 RenderProxyBox([RenderBox child = null]) { 441 RenderProxyBox([RenderBox child = null]) {
440 this.child = child; 442 this.child = child;
441 } 443 }
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after
1344 return true; 1346 return true;
1345 } 1347 }
1346 1348
1347 void paint(PaintingCanvas canvas, Offset offset) { 1349 void paint(PaintingCanvas canvas, Offset offset) {
1348 if (child != null) 1350 if (child != null)
1349 canvas.paintChild(child, offset.toPoint()); 1351 canvas.paintChild(child, offset.toPoint());
1350 } 1352 }
1351 1353
1352 void paintFrame() { 1354 void paintFrame() {
1353 sky.tracing.begin('RenderView.paintFrame'); 1355 sky.tracing.begin('RenderView.paintFrame');
1354 RenderObject.debugDoingPaint = true;
1355 try { 1356 try {
1356 sky.PictureRecorder recorder = new sky.PictureRecorder(); 1357 sky.PictureRecorder recorder = new sky.PictureRecorder();
1357 PaintingCanvas canvas = new PaintingCanvas(recorder, _size); 1358 PaintingCanvas canvas = new PaintingCanvas(recorder, paintBounds);
1358 paint(canvas, Offset.zero); 1359 canvas.drawPaintingNode(paintingNode);
1359 sky.view.picture = recorder.endRecording(); 1360 sky.view.picture = recorder.endRecording();
1360 } finally { 1361 } finally {
1361 RenderObject.debugDoingPaint = false;
1362 sky.tracing.end('RenderView.paintFrame'); 1362 sky.tracing.end('RenderView.paintFrame');
1363 } 1363 }
1364 } 1364 }
1365 1365
1366 Rect get paintBounds => Point.origin & size;
1366 } 1367 }
1367 1368
1368 // HELPER METHODS FOR RENDERBOX CONTAINERS 1369 // HELPER METHODS FOR RENDERBOX CONTAINERS
1369 abstract class RenderBoxContainerDefaultsMixin<ChildType extends RenderBox, Pare ntDataType extends ContainerParentDataMixin<ChildType>> implements ContainerRend erObjectMixin<ChildType, ParentDataType> { 1370 abstract class RenderBoxContainerDefaultsMixin<ChildType extends RenderBox, Pare ntDataType extends ContainerParentDataMixin<ChildType>> implements ContainerRend erObjectMixin<ChildType, ParentDataType> {
1370 1371
1371 // This class, by convention, doesn't override any members of the superclass. 1372 // This class, by convention, doesn't override any members of the superclass.
1372 // It only provides helper functions that subclasses can call. 1373 // It only provides helper functions that subclasses can call.
1373 1374
1374 double defaultComputeDistanceToFirstActualBaseline(TextBaseline baseline) { 1375 double defaultComputeDistanceToFirstActualBaseline(TextBaseline baseline) {
1375 assert(!needsLayout); 1376 assert(!needsLayout);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1420 1421
1421 void defaultPaint(PaintingCanvas canvas, Offset offset) { 1422 void defaultPaint(PaintingCanvas canvas, Offset offset) {
1422 RenderBox child = firstChild; 1423 RenderBox child = firstChild;
1423 while (child != null) { 1424 while (child != null) {
1424 assert(child.parentData is ParentDataType); 1425 assert(child.parentData is ParentDataType);
1425 canvas.paintChild(child, child.parentData.position + offset); 1426 canvas.paintChild(child, child.parentData.position + offset);
1426 child = child.parentData.nextSibling; 1427 child = child.parentData.nextSibling;
1427 } 1428 }
1428 } 1429 }
1429 } 1430 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698