OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 | 5 |
6 /** | 6 /** |
7 * @fileoverview Provides a mechanism for drawing massive numbers of | 7 * @fileoverview Provides a mechanism for drawing massive numbers of |
8 * colored rectangles into a canvas in an efficient manner, provided | 8 * colored rectangles into a canvas in an efficient manner, provided |
9 * they are drawn left to right with fixed y and height throughout. | 9 * they are drawn left to right with fixed y and height throughout. |
10 * | 10 * |
11 * The basic idea used here is to fuse subpixel rectangles together so that | 11 * The basic idea used here is to fuse subpixel rectangles together so that |
12 * we never issue a canvas fillRect for them. It turns out Javascript can | 12 * we never issue a canvas fillRect for them. It turns out Javascript can |
13 * do this quite efficiently, compared to asking Canvas2D to do the same. | 13 * do this quite efficiently, compared to asking Canvas2D to do the same. |
14 * | 14 * |
15 * A few extra things are done by this class in the name of speed: | 15 * A few extra things are done by this class in the name of speed: |
16 * - Viewport culling: off-viewport rectangles are discarded. | 16 * - Viewport culling: off-viewport rectangles are discarded. |
17 * | 17 * |
18 * - The actual discarding operation is done in world space, | 18 * - The actual discarding operation is done in world space, |
19 * e.g. pre-transform. | 19 * e.g. pre-transform. |
20 * | 20 * |
21 * - Rather than expending compute cycles trying to figure out an average | 21 * - Rather than expending compute cycles trying to figure out an average |
22 * color for fused rectangles from css strings, you instead draw using | 22 * color for fused rectangles from css strings, you instead draw using |
23 * palletized colors. The fused rect is the max pallete index encountered. | 23 * palletized colors. The fused rect is the max pallete index encountered. |
24 * | 24 * |
25 * Make sure to flush the trackRenderer before finishing drawing in order | 25 * Make sure to flush the trackRenderer before finishing drawing in order |
26 * to commit any queued drawing operations. | 26 * to commit any queued drawing operations. |
27 */ | 27 */ |
28 cr.define('gpu', function() { | 28 cr.define('tracing', function() { |
29 | 29 |
30 /** | 30 /** |
31 * Creates a fast rect renderer with a specific set of culling rules | 31 * Creates a fast rect renderer with a specific set of culling rules |
32 * and color pallette. | 32 * and color pallette. |
33 * @param {GraphicsContext2D} ctx Canvas2D drawing context. | 33 * @param {GraphicsContext2D} ctx Canvas2D drawing context. |
34 * @param {number} vpLeft The leftmost visible part of the drawing viewport. | 34 * @param {number} vpLeft The leftmost visible part of the drawing viewport. |
35 * @param {number} minRectSize Only rectangles with width < minRectSize are | 35 * @param {number} minRectSize Only rectangles with width < minRectSize are |
36 * considered for merging. | 36 * considered for merging. |
37 * @param {number} maxMergeDist Controls how many successive small rectangles | 37 * @param {number} maxMergeDist Controls how many successive small rectangles |
38 * can be merged together before issuing a rectangle. | 38 * can be merged together before issuing a rectangle. |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 this.merging_ = false; | 111 this.merging_ = false; |
112 } | 112 } |
113 } | 113 } |
114 }; | 114 }; |
115 | 115 |
116 return { | 116 return { |
117 FastRectRenderer: FastRectRenderer | 117 FastRectRenderer: FastRectRenderer |
118 }; | 118 }; |
119 | 119 |
120 }); | 120 }); |
OLD | NEW |