Adam Barth fc576814d5 Refactor PaintingContext
This patch simplifies PaintingContext with several goals:

1) We now call a callback instead of assuming the caller has a single child to
   paint. This change will let us handle render objects that wish to paint more
   than one child.
2) We now avoid creating lots of empty picture layers because we don't eagerly
   start recording pictures. Instead, we wait for the first caller to touch the
   canvas before creating the picture recorder.
3) We now are more consistent about which values have incorporated the painting
   offset.
2015-11-19 11:18:04 -08:00

60 lines
1.5 KiB
Dart

// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'box.dart';
import 'object.dart';
class RenderStatisticsBox extends RenderBox {
RenderStatisticsBox({int optionsMask: 0, int rasterizerThreshold: 0})
: _optionsMask = optionsMask,
_rasterizerThreshold = rasterizerThreshold;
int _optionsMask;
int get optionsMask => _optionsMask;
void set optionsMask (int mask) {
if (mask == _optionsMask) {
return;
}
_optionsMask = mask;
markNeedsPaint();
}
int _rasterizerThreshold;
int get rasterizerThreshold => _rasterizerThreshold;
void set rasterizerThreshold (int threshold) {
if (threshold == _rasterizerThreshold) {
return;
}
_rasterizerThreshold = threshold;
markNeedsPaint();
}
bool get sizedByParent => true;
double getMinIntrinsicWidth(BoxConstraints constraints) {
return constraints.minWidth;
}
double getMaxIntrinsicWidth(BoxConstraints constraints) {
return constraints.maxWidth;
}
double getMinIntrinsicHeight(BoxConstraints constraints) {
return constraints.minHeight;
}
double getMaxIntrinsicHeight(BoxConstraints constraints) {
return constraints.maxHeight;
}
void performResize() {
size = constraints.biggest;
}
void paint(PaintingContext context, Offset offset) {
context.pushStatistics(offset, optionsMask, rasterizerThreshold, size);
}
}