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

Unified Diff: sky/sdk/example/raw/painting_node.dart

Issue 1216833003: Make rendering use PaintingNodes for increased efficiency. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Different approach to calling markNeedsPaint with unattached nodes 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/engine/platform/graphics/DecodingImageGenerator.h ('k') | sky/sdk/lib/rendering/box.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/sdk/example/raw/painting_node.dart
diff --git a/sky/sdk/example/raw/hello_world.dart b/sky/sdk/example/raw/painting_node.dart
similarity index 59%
copy from sky/sdk/example/raw/hello_world.dart
copy to sky/sdk/example/raw/painting_node.dart
index e667391734b3dcfd9f595a90d706ab33c6d84b98..7297540ee4df303e208aed57ef4c1ee652027343 100644
--- a/sky/sdk/example/raw/hello_world.dart
+++ b/sky/sdk/example/raw/painting_node.dart
@@ -2,17 +2,32 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+import "dart:math";
import 'dart:sky';
+PaintingNode paintingNode = null;
Picture draw(int a, int r, int g, int b) {
+ Rect bounds = new Rect.fromLTRB(0.0, 0.0, view.width, view.height);
Size size = new Size(view.width, view.height);
PictureRecorder recorder = new PictureRecorder();
- Canvas canvas = new Canvas(recorder, size);
+ Canvas canvas = new Canvas(recorder, bounds);
double radius = size.shortestSide * 0.45;
Paint paint = new Paint()..color = new Color.fromARGB(a, r, g, b);
canvas.drawCircle(size.center(Point.origin), radius, paint);
+
+ if (paintingNode == null) {
+ paintingNode = new PaintingNode();
+ Paint innerPaint = new Paint()..color = new Color.fromARGB(a, 255 - r, 255 - g, 255 - b);
+ PictureRecorder innerRecorder = new PictureRecorder();
+ Canvas innerCanvas = new Canvas(innerRecorder, bounds);
+ innerCanvas.drawCircle(size.center(Point.origin), radius * 0.5, innerPaint);
+
+ paintingNode.setBackingDrawable(innerRecorder.endRecordingAsDrawable());
+ }
+ canvas.drawPaintingNode(paintingNode);
+
return recorder.endRecording();
}
@@ -29,16 +44,10 @@ bool handleEvent(Event event) {
return true;
}
- if (event.type == "back") {
- print("Pressed back button.");
- return true;
- }
-
return false;
}
void main() {
- print("Hello, world");
view.picture = draw(255, 0, 255, 0);
view.scheduleFrame();
« no previous file with comments | « sky/engine/platform/graphics/DecodingImageGenerator.h ('k') | sky/sdk/lib/rendering/box.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698