OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "core/paint/BoxPainter.h" | 5 #include "core/paint/BoxPainter.h" |
6 | 6 |
7 #include "core/HTMLNames.h" | 7 #include "core/HTMLNames.h" |
8 #include "core/frame/Settings.h" | 8 #include "core/frame/Settings.h" |
9 #include "core/html/HTMLFrameOwnerElement.h" | 9 #include "core/html/HTMLFrameOwnerElement.h" |
10 #include "core/layout/ImageQualityController.h" | 10 #include "core/layout/ImageQualityController.h" |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 return; | 206 return; |
207 if (layout_box_.BackgroundStolenForBeingBody()) | 207 if (layout_box_.BackgroundStolenForBeingBody()) |
208 return; | 208 return; |
209 if (layout_box_.BackgroundIsKnownToBeObscured()) | 209 if (layout_box_.BackgroundIsKnownToBeObscured()) |
210 return; | 210 return; |
211 PaintFillLayers(paint_info, background_color, | 211 PaintFillLayers(paint_info, background_color, |
212 layout_box_.Style()->BackgroundLayers(), paint_rect, | 212 layout_box_.Style()->BackgroundLayers(), paint_rect, |
213 bleed_avoidance); | 213 bleed_avoidance); |
214 } | 214 } |
215 | 215 |
216 bool BoxPainter::CalculateFillLayerOcclusionCulling( | |
217 FillLayerOcclusionOutputList& reversed_paint_list, | |
218 const FillLayer& fill_layer) { | |
219 bool is_non_associative = false; | |
220 for (auto current_layer = &fill_layer; current_layer; | |
221 current_layer = current_layer->Next()) { | |
222 reversed_paint_list.push_back(current_layer); | |
223 // Stop traversal when an opaque layer is encountered. | |
224 // FIXME : It would be possible for the following occlusion culling test to | |
225 // be more aggressive on layers with no repeat by testing whether the image | |
226 // covers the layout rect. Testing that here would imply duplicating a lot | |
227 // of calculations that are currently done in | |
228 // LayoutBoxModelObject::paintFillLayer. A more efficient solution might be | |
229 // to move the layer recursion into paintFillLayer, or to compute the layer | |
230 // geometry here and pass it down. | |
231 | |
232 // TODO(trchen): Need to check compositing mode as well. | |
233 if (current_layer->BlendMode() != kWebBlendModeNormal) | |
234 is_non_associative = true; | |
235 | |
236 // TODO(trchen): A fill layer cannot paint if the calculated tile size is | |
237 // empty. This occlusion check can be wrong. | |
238 if (current_layer->ClipOccludesNextLayers() && | |
239 current_layer->ImageOccludesNextLayers(layout_box_.GetDocument(), | |
240 layout_box_.StyleRef())) { | |
241 if (current_layer->Clip() == kBorderFillBox) | |
242 is_non_associative = false; | |
243 break; | |
244 } | |
245 } | |
246 return is_non_associative; | |
247 } | |
248 | |
249 void BoxPainter::PaintFillLayers(const PaintInfo& paint_info, | 216 void BoxPainter::PaintFillLayers(const PaintInfo& paint_info, |
250 const Color& c, | 217 const Color& c, |
251 const FillLayer& fill_layer, | 218 const FillLayer& fill_layer, |
252 const LayoutRect& rect, | 219 const LayoutRect& rect, |
253 BackgroundBleedAvoidance bleed_avoidance, | 220 BackgroundBleedAvoidance bleed_avoidance, |
254 SkBlendMode op, | 221 SkBlendMode op, |
255 const LayoutObject* background_object) { | 222 const LayoutObject* background_object) { |
256 FillLayerOcclusionOutputList reversed_paint_list; | 223 FillLayerOcclusionOutputList reversed_paint_list; |
257 bool should_draw_background_in_separate_buffer = | 224 bool should_draw_background_in_separate_buffer = |
258 CalculateFillLayerOcclusionCulling(reversed_paint_list, fill_layer); | 225 CalculateFillLayerOcclusionCulling(reversed_paint_list, fill_layer, |
| 226 layout_box_.GetDocument(), |
| 227 layout_box_.StyleRef()); |
259 | 228 |
260 // TODO(trchen): We can optimize out isolation group if we have a | 229 // TODO(trchen): We can optimize out isolation group if we have a |
261 // non-transparent background color and the bottom layer encloses all other | 230 // non-transparent background color and the bottom layer encloses all other |
262 // layers. | 231 // layers. |
263 | 232 |
264 GraphicsContext& context = paint_info.context; | 233 GraphicsContext& context = paint_info.context; |
265 | 234 |
266 if (should_draw_background_in_separate_buffer) | 235 if (should_draw_background_in_separate_buffer) |
267 context.BeginLayer(); | 236 context.BeginLayer(); |
268 | 237 |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
871 if (PaintNinePieceImage(obj, info.context, rect, style, style.BorderImage())) | 840 if (PaintNinePieceImage(obj, info.context, rect, style, style.BorderImage())) |
872 return; | 841 return; |
873 | 842 |
874 const BoxBorderPainter border_painter(rect, style, bleed_avoidance, | 843 const BoxBorderPainter border_painter(rect, style, bleed_avoidance, |
875 include_logical_left_edge, | 844 include_logical_left_edge, |
876 include_logical_right_edge); | 845 include_logical_right_edge); |
877 border_painter.PaintBorder(info, rect); | 846 border_painter.PaintBorder(info, rect); |
878 } | 847 } |
879 | 848 |
880 } // namespace blink | 849 } // namespace blink |
OLD | NEW |