Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
|
fserb
2017/05/24 20:54:18
nit: this should really be a git mv so we keep his
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CanvasHeuristicParameters_h | |
| 6 #define CanvasHeuristicParameters_h | |
| 7 | |
| 8 namespace blink { | |
| 9 | |
| 10 namespace CanvasHeuristicParameters { | |
| 11 | |
| 12 enum { | |
| 13 // Layer promotion heuristic parameters | |
| 14 //====================================== | |
| 15 | |
| 16 // FIXME (crbug.com/463239): | |
| 17 // The Layer promotion heuristics should go away after slimming paint | |
| 18 // is completely phased in and display list canvases are modified to | |
| 19 // use a lightweight layering primitive instead of the | |
| 20 // SkCanvas::saveLayer. | |
| 21 | |
| 22 // Heuristic: Canvases that are overdrawn beyond this factor in a | |
| 23 // single frame are promoted to a direct composited layer so that | |
| 24 // their contents not be re-rasterized by the compositor when the | |
| 25 // containing layer is the object of a paint invalidation. | |
| 26 kExpensiveOverdrawThreshold = 3, | |
| 27 | |
| 28 kExpensivePathPointCount = 50, | |
| 29 | |
| 30 kSVGImageSourcesAreExpensive = 1, | |
| 31 | |
| 32 kConcavePathsAreExpensive = 1, | |
| 33 | |
| 34 kComplexClipsAreExpensive = 1, | |
| 35 | |
| 36 kBlurredShadowsAreExpensive = 1, | |
| 37 | |
| 38 // Heuristic: When drawing a source image that has more pixels than | |
| 39 // the destination canvas by the following factor or more, the draw | |
| 40 // is considered expensive. | |
| 41 kExpensiveImageSizeRatio = 4, | |
| 42 | |
| 43 // Display list fallback heuristic parameters | |
| 44 //============================================ | |
| 45 | |
| 46 // Frames ending with more than this number of levels remaining | |
| 47 // on the state stack at the end of a frame are too expensive to | |
| 48 // remain in display list mode. This criterion is motivated by an | |
| 49 // O(N) cost in carying over state from one frame to the next when | |
| 50 // in display list mode. The value of this parameter should be high | |
| 51 // enough to almost never kick in other than for cases with unmatched | |
| 52 // save()/restore() calls are low enough to kick in before state | |
| 53 // management becomes measurably expensive. | |
| 54 kExpensiveRecordingStackDepth = 50, | |
| 55 | |
| 56 // GPU vs. display list heuristic parameters | |
| 57 //=========================================== | |
| 58 | |
| 59 // Pixel count beyond which we should always prefer to use display | |
| 60 // lists. Rationale: The allocation of large textures for canvas | |
| 61 // tends to starve the compositor, and increase the probability of | |
| 62 // failure of subsequent allocations required for double buffering. | |
| 63 kPreferDisplayListOverGpuSizeThreshold = 8096 * 4096, | |
| 64 | |
| 65 // Disable Acceleration heuristic parameters | |
| 66 //=========================================== | |
| 67 | |
| 68 // When drawing very large images to canvases, there is a point where | |
| 69 // GPU acceleration becomes inefficient due to texture upload overhead, | |
| 70 // especially when the image is large enough that it is likely to | |
| 71 // monopolize the texture cache, and when it is being downsized to the | |
| 72 // point that few of the upload texels are actually sampled. When both | |
| 73 // of these conditions are met, we disable acceleration. | |
| 74 kDrawImageTextureUploadSoftSizeLimit = 4096 * 4096, | |
| 75 kDrawImageTextureUploadSoftSizeLimitScaleThreshold = 4, | |
| 76 kDrawImageTextureUploadHardSizeLimit = 8192 * 8192, | |
| 77 | |
| 78 // GPU readback prevention heuristics | |
| 79 //==================================== | |
| 80 | |
| 81 kGPUReadbackForcesNoAcceleration = 1, | |
| 82 | |
| 83 // When gpu readback is successively invoked in following number of frames, | |
| 84 // we disable gpu acceleration to avoid the high cost of gpu readback. | |
| 85 kGPUReadbackMinSuccessiveFrames = 3, | |
| 86 | |
| 87 // When a canvas is used as a source image, if its destination is | |
| 88 // non-accelerated and the source canvas is accelerated, a readback | |
| 89 // from the gpu is necessary. This option causes the source canvas to | |
| 90 // switch to non-accelerated when this situation is encountered to | |
| 91 // prevent future canvas-to-canvas draws from requiring a readback. | |
| 92 kDisableAccelerationToAvoidReadbacks = 0, | |
| 93 | |
| 94 // See description of DisableAccelerationToAvoidReadbacks. This is the | |
| 95 // opposite strategy : accelerate the destination canvas. If both | |
| 96 // EnableAccelerationToAvoidReadbacks and | |
| 97 // DisableAccelerationToAvoidReadbacks are specified, we try to enable | |
| 98 // acceleration on the destination first. If that does not succeed, | |
| 99 // we disable acceleration on the source canvas. Either way, future | |
| 100 // readbacks are prevented. | |
| 101 kEnableAccelerationToAvoidReadbacks = 1, | |
| 102 | |
| 103 }; // enum | |
| 104 | |
| 105 } // namespace CanvasHeuristicParameters | |
| 106 | |
| 107 } // namespace blink | |
| 108 | |
| 109 #endif | |
| OLD | NEW |