OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 // Need to include something before #if SK_SUPPORT_GPU so that the Android | 8 // Need to include something before #if SK_SUPPORT_GPU so that the Android |
9 // framework build, which gets its defines from SkTypes rather than a makefile, | 9 // framework build, which gets its defines from SkTypes rather than a makefile, |
10 // has the definition before checking it. | 10 // has the definition before checking it. |
11 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
12 #include "SkMultiPictureDraw.h" | 12 #include "SkMultiPictureDraw.h" |
13 #include "SkPicture.h" | 13 #include "SkPicture.h" |
14 #include "SkTaskGroup.h" | 14 #include "SkTaskGroup.h" |
15 | 15 |
16 #if SK_SUPPORT_GPU | 16 #if SK_SUPPORT_GPU |
17 #include "GrLayerHoister.h" | 17 #include "GrLayerHoister.h" |
18 #include "GrRecordReplaceDraw.h" | 18 #include "GrRecordReplaceDraw.h" |
| 19 #include "GrRenderTarget.h" |
19 #endif | 20 #endif |
20 | 21 |
21 void SkMultiPictureDraw::DrawData::draw() { | 22 void SkMultiPictureDraw::DrawData::draw() { |
22 fCanvas->drawPicture(fPicture, &fMatrix, fPaint); | 23 fCanvas->drawPicture(fPicture, &fMatrix, fPaint); |
23 } | 24 } |
24 | 25 |
25 void SkMultiPictureDraw::DrawData::init(SkCanvas* canvas, const SkPicture* pictu
re, | 26 void SkMultiPictureDraw::DrawData::init(SkCanvas* canvas, const SkPicture* pictu
re, |
26 const SkMatrix* matrix, const SkPaint* p
aint) { | 27 const SkMatrix* matrix, const SkPaint* p
aint) { |
27 fPicture = SkRef(picture); | 28 fPicture = SkRef(picture); |
28 fCanvas = SkRef(canvas); | 29 fCanvas = SkRef(canvas); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 if (!data.fPaint && data.fMatrix.isIdentity()) { | 114 if (!data.fPaint && data.fMatrix.isIdentity()) { |
114 // TODO: this path always tries to optimize pictures. Should we | 115 // TODO: this path always tries to optimize pictures. Should we |
115 // switch to this API approach (vs. SkCanvas::EXPERIMENTAL_optimize)
? | 116 // switch to this API approach (vs. SkCanvas::EXPERIMENTAL_optimize)
? |
116 data.fCanvas->EXPERIMENTAL_optimize(data.fPicture); | 117 data.fCanvas->EXPERIMENTAL_optimize(data.fPicture); |
117 | 118 |
118 SkRect clipBounds; | 119 SkRect clipBounds; |
119 if (!data.fCanvas->getClipBounds(&clipBounds)) { | 120 if (!data.fCanvas->getClipBounds(&clipBounds)) { |
120 continue; | 121 continue; |
121 } | 122 } |
122 | 123 |
| 124 GrRenderTarget* rt = data.fCanvas->internal_private_accessTopLayerRe
nderTarget(); |
| 125 SkASSERT(rt); |
| 126 |
123 // TODO: sorting the cacheable layers from smallest to largest | 127 // TODO: sorting the cacheable layers from smallest to largest |
124 // would improve the packing and reduce the number of swaps | 128 // would improve the packing and reduce the number of swaps |
125 // TODO: another optimization would be to make a first pass to | 129 // TODO: another optimization would be to make a first pass to |
126 // lock any required layer that is already in the atlas | 130 // lock any required layer that is already in the atlas |
127 GrLayerHoister::FindLayersToAtlas(context, data.fPicture, | 131 GrLayerHoister::FindLayersToAtlas(context, data.fPicture, |
128 clipBounds, | 132 clipBounds, |
129 &atlasedNeedRendering, &atlasedRec
ycled); | 133 &atlasedNeedRendering, &atlasedRec
ycled, |
| 134 rt->numSamples()); |
130 } | 135 } |
131 } | 136 } |
132 | 137 |
133 GrLayerHoister::DrawLayersToAtlas(context, atlasedNeedRendering); | 138 GrLayerHoister::DrawLayersToAtlas(context, atlasedNeedRendering); |
134 | 139 |
135 SkTDArray<GrHoistedLayer> needRendering, recycled; | 140 SkTDArray<GrHoistedLayer> needRendering, recycled; |
136 #endif | 141 #endif |
137 | 142 |
138 for (int i = 0; i < count; ++i) { | 143 for (int i = 0; i < count; ++i) { |
139 const DrawData& data = fGPUDrawData[i]; | 144 const DrawData& data = fGPUDrawData[i]; |
140 SkCanvas* canvas = data.fCanvas; | 145 SkCanvas* canvas = data.fCanvas; |
141 const SkPicture* picture = data.fPicture; | 146 const SkPicture* picture = data.fPicture; |
142 | 147 |
143 #if !defined(SK_IGNORE_GPU_LAYER_HOISTING) && SK_SUPPORT_GPU | 148 #if !defined(SK_IGNORE_GPU_LAYER_HOISTING) && SK_SUPPORT_GPU |
144 if (!data.fPaint && data.fMatrix.isIdentity()) { | 149 if (!data.fPaint && data.fMatrix.isIdentity()) { |
145 | 150 |
146 SkRect clipBounds; | 151 SkRect clipBounds; |
147 if (!canvas->getClipBounds(&clipBounds)) { | 152 if (!canvas->getClipBounds(&clipBounds)) { |
148 continue; | 153 continue; |
149 } | 154 } |
150 | 155 |
| 156 GrRenderTarget* rt = data.fCanvas->internal_private_accessTopLayerRe
nderTarget(); |
| 157 SkASSERT(rt); |
| 158 |
151 // Find the layers required by this canvas. It will return atlased | 159 // Find the layers required by this canvas. It will return atlased |
152 // layers in the 'recycled' list since they have already been drawn. | 160 // layers in the 'recycled' list since they have already been drawn. |
153 GrLayerHoister::FindLayersToHoist(context, picture, | 161 GrLayerHoister::FindLayersToHoist(context, picture, |
154 clipBounds, &needRendering, &recyc
led); | 162 clipBounds, &needRendering, &recyc
led, |
| 163 rt->numSamples()); |
155 | 164 |
156 GrLayerHoister::DrawLayers(context, needRendering); | 165 GrLayerHoister::DrawLayers(context, needRendering); |
157 | 166 |
158 GrReplacements replacements; | 167 GrReplacements replacements; |
159 | 168 |
160 GrLayerHoister::ConvertLayersToReplacements(needRendering, &replacem
ents); | 169 GrLayerHoister::ConvertLayersToReplacements(needRendering, &replacem
ents); |
161 GrLayerHoister::ConvertLayersToReplacements(recycled, &replacements)
; | 170 GrLayerHoister::ConvertLayersToReplacements(recycled, &replacements)
; |
162 | 171 |
163 const SkMatrix initialMatrix = canvas->getTotalMatrix(); | 172 const SkMatrix initialMatrix = canvas->getTotalMatrix(); |
164 | 173 |
(...skipping 14 matching lines...) Expand all Loading... |
179 | 188 |
180 #if !defined(SK_IGNORE_GPU_LAYER_HOISTING) && SK_SUPPORT_GPU | 189 #if !defined(SK_IGNORE_GPU_LAYER_HOISTING) && SK_SUPPORT_GPU |
181 GrLayerHoister::UnlockLayers(context, atlasedNeedRendering); | 190 GrLayerHoister::UnlockLayers(context, atlasedNeedRendering); |
182 GrLayerHoister::UnlockLayers(context, atlasedRecycled); | 191 GrLayerHoister::UnlockLayers(context, atlasedRecycled); |
183 #if !GR_CACHE_HOISTED_LAYERS | 192 #if !GR_CACHE_HOISTED_LAYERS |
184 GrLayerHoister::PurgeCache(context); | 193 GrLayerHoister::PurgeCache(context); |
185 #endif | 194 #endif |
186 #endif | 195 #endif |
187 } | 196 } |
188 | 197 |
OLD | NEW |