| OLD | NEW |
| 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, Offset, Size, Rect, Color, Paint, Path; | 7 import 'dart:sky' show Point, Offset, Size, Rect, Color, Paint, Path; |
| 8 | 8 |
| 9 import 'package:sky/base/debug.dart'; | 9 import 'package:sky/base/debug.dart'; |
| 10 import 'package:sky/base/hit_test.dart'; | 10 import 'package:sky/base/hit_test.dart'; |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 _paintOnCanvas(canvas, Offset.zero); | 363 _paintOnCanvas(canvas, Offset.zero); |
| 364 } catch (e) { | 364 } catch (e) { |
| 365 print('Exception raised during _updatePaintingCanvas:\n${e}\nContext:\n${t
his}'); | 365 print('Exception raised during _updatePaintingCanvas:\n${e}\nContext:\n${t
his}'); |
| 366 if (inDebugBuild) | 366 if (inDebugBuild) |
| 367 rethrow; | 367 rethrow; |
| 368 return; | 368 return; |
| 369 } | 369 } |
| 370 assert(!_needsLayout); // check that the paint() method didn't mark us dirty
again | 370 assert(!_needsLayout); // check that the paint() method didn't mark us dirty
again |
| 371 assert(!_needsPaint); // check that the paint() method didn't mark us dirty
again | 371 assert(!_needsPaint); // check that the paint() method didn't mark us dirty
again |
| 372 _paintingNode.setBackingDrawable(recorder.endRecordingAsDrawable()); | 372 _paintingNode.setBackingDrawable(recorder.endRecordingAsDrawable()); |
| 373 | |
| 374 if (canvas._descendentsWithPaintingCanvases != null) { | 373 if (canvas._descendentsWithPaintingCanvases != null) { |
| 375 for (RenderObject node in canvas._descendentsWithPaintingCanvases) { | 374 for (RenderObject node in canvas._descendentsWithPaintingCanvases) { |
| 376 assert(node.attached == attached); | 375 assert(node.attached == attached); |
| 377 if (node._needsPaint) | 376 if (node._needsPaint) |
| 378 node._updatePaintingCanvas(); | 377 node._updatePaintingCanvas(); |
| 379 }; | 378 }; |
| 380 } | 379 } |
| 381 } | 380 } |
| 382 | 381 |
| 383 void _paintOnCanvas(PaintingCanvas canvas, Offset offset) { | 382 void _paintOnCanvas(PaintingCanvas canvas, Offset offset) { |
| 384 _needsPaint = false; | 383 _needsPaint = false; |
| 385 assert(!_debugDoingThisPaint); | 384 assert(!_debugDoingThisPaint); |
| 386 RenderObject debugLastActivePaint; | 385 RenderObject debugLastActivePaint; |
| 387 assert(() { | 386 assert(() { |
| 388 _debugDoingThisPaint = true; | 387 _debugDoingThisPaint = true; |
| 389 debugLastActivePaint = _debugActivePaint; | 388 debugLastActivePaint = _debugActivePaint; |
| 390 _debugActivePaint = this; | 389 _debugActivePaint = this; |
| 390 debugPaint(canvas, offset); |
| 391 if (debugPaintBoundsEnabled) { |
| 392 canvas.save(); |
| 393 canvas.clipRect(paintBounds.shift(offset)); |
| 394 } |
| 391 return true; | 395 return true; |
| 392 }); | 396 }); |
| 393 paint(canvas, offset); | 397 paint(canvas, offset); |
| 394 assert(() { | 398 assert(() { |
| 399 if (debugPaintBoundsEnabled) |
| 400 canvas.restore(); |
| 395 _debugActivePaint = debugLastActivePaint; | 401 _debugActivePaint = debugLastActivePaint; |
| 396 _debugDoingThisPaint = false; | 402 _debugDoingThisPaint = false; |
| 397 return true; | 403 return true; |
| 398 }); | 404 }); |
| 399 assert(!_needsPaint); | 405 assert(!_needsPaint); |
| 400 } | 406 } |
| 401 | 407 |
| 402 bool get createNewDisplayList => false; | 408 bool get createNewDisplayList => false; |
| 403 Rect get paintBounds; | 409 Rect get paintBounds; |
| 410 void debugPaint(PaintingCanvas canvas, Offset offset) { } |
| 404 void paint(PaintingCanvas canvas, Offset offset) { } | 411 void paint(PaintingCanvas canvas, Offset offset) { } |
| 405 | 412 |
| 406 | 413 |
| 407 // EVENTS | 414 // EVENTS |
| 408 | 415 |
| 409 void handleEvent(sky.Event event, HitTestEntry entry) { | 416 void handleEvent(sky.Event event, HitTestEntry entry) { |
| 410 // override this if you have a client, to hand it to the client | 417 // override this if you have a client, to hand it to the client |
| 411 // override this if you want to do anything with the event | 418 // override this if you want to do anything with the event |
| 412 } | 419 } |
| 413 | 420 |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 int count = 1; | 708 int count = 1; |
| 702 ChildType child = _firstChild; | 709 ChildType child = _firstChild; |
| 703 while (child != null) { | 710 while (child != null) { |
| 704 result += '${prefix}child ${count}: ${child.toString(prefix)}'; | 711 result += '${prefix}child ${count}: ${child.toString(prefix)}'; |
| 705 count += 1; | 712 count += 1; |
| 706 child = child.parentData.nextSibling; | 713 child = child.parentData.nextSibling; |
| 707 } | 714 } |
| 708 return result; | 715 return result; |
| 709 } | 716 } |
| 710 } | 717 } |
| OLD | NEW |