Skip to content

Commit

Permalink
other
Browse files Browse the repository at this point in the history
  • Loading branch information
QiXi committed Sep 23, 2021
1 parent 0a75056 commit 359951b
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions lib/src/batch/batch_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class BatchData {
}

void fillOneUnit(Float32List rstTransforms, Float32List rect, int color, [int skipCount = 0]) {
//TODO performance
final index0 = currentIndex;
rawTransforms.setRange(index0, index0 + 4, rstTransforms, skipCount);
rawSources.setRange(index0, index0 + 4, rect, skipCount);
Expand Down
2 changes: 1 addition & 1 deletion lib/src/components/text_component.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class TextComponent extends Component with Dirty {
);
final TextPainter _textPainter;
final DrawableText _drawable;
var _textStyle;
final TextStyle _textStyle;
String _text;

TextComponent(this._text, RenderComponent renderComponent, {TextStyle? style})
Expand Down
7 changes: 4 additions & 3 deletions lib/src/core/object_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class ObjectManager<T extends BaseObject> extends BaseObject {

List<T> getAdditionsArray() => _pendingAdditions;

List<T> getRemovalsArray() => _pendingRemovals;

void add(T object) {
_pendingAdditions.add(object);
}
Expand All @@ -80,14 +82,13 @@ class ObjectManager<T extends BaseObject> extends BaseObject {
}

E? _findByType<E extends BaseObject>(List<T> _objectArray) {
final count = _objectArray.length;
for (var i = 0; i < count; i++) {
final length = _objectArray.length;
for (var i = 0; i < length; i++) {
var currentObject = _objectArray[i];
if (currentObject.runtimeType == E) {
return currentObject as E;
}
}
return null;
}

@override
Expand Down
1 change: 1 addition & 0 deletions lib/src/core/sorted_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class SortedList<T> {
}

void sort(bool forceResort) {
//TODO performance
if (!_sorted || forceResort) {
if (_comparator != null) {
data.sort(_comparator);
Expand Down
4 changes: 2 additions & 2 deletions test/engine_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import 'package:composition_rendering/batch.dart';
import 'package:test/test.dart';

void main() {
final defaultColor = 0xffffffff;
const defaultColor = 0xffffffff;
test('EngineBatch.drawImage', () async {
final image = await _createImage(1, 1);
final bath = EngineBatch(capacity: 2);
bath.drawImageFromData(image, Rect.fromLTWH(0, 0, 1, 1), 1, 0, 0, 0, defaultColor);
bath.drawImageFromData(image, const Rect.fromLTWH(0, 0, 1, 1), 1, 0, 0, 0, defaultColor);
expect(bath.rectCount, 1);
expect(bath.freeLength, 4);
var rawSprite = Float32List.fromList([1, 0, 10, 10, 1, 0, 20, 20, 1, 0, 30, 30]);
Expand Down

0 comments on commit 359951b

Please sign in to comment.