| 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 "platform/graphics/paint/DrawingRecorder.h" | 5 #include "platform/graphics/paint/DrawingRecorder.h" |
| 6 | 6 |
| 7 #include "platform/RuntimeEnabledFeatures.h" | 7 #include "platform/RuntimeEnabledFeatures.h" |
| 8 #include "platform/graphics/GraphicsContext.h" | 8 #include "platform/graphics/GraphicsContext.h" |
| 9 #include "platform/graphics/GraphicsLayer.h" | 9 #include "platform/graphics/GraphicsLayer.h" |
| 10 #include "platform/graphics/paint/PaintController.h" | 10 #include "platform/graphics/paint/PaintController.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 m_knownToBeOpaque(false) | 22 m_knownToBeOpaque(false) |
| 23 #if DCHECK_IS_ON() | 23 #if DCHECK_IS_ON() |
| 24 , | 24 , |
| 25 m_displayItemPosition( | 25 m_displayItemPosition( |
| 26 m_context.getPaintController().newDisplayItemList().size()) | 26 m_context.getPaintController().newDisplayItemList().size()) |
| 27 #endif | 27 #endif |
| 28 { | 28 { |
| 29 if (context.getPaintController().displayItemConstructionIsDisabled()) | 29 if (context.getPaintController().displayItemConstructionIsDisabled()) |
| 30 return; | 30 return; |
| 31 | 31 |
| 32 // Must check DrawingRecorder::useCachedDrawingIfPossible before creating the
DrawingRecorder. | 32 // Must check DrawingRecorder::useCachedDrawingIfPossible before creating the |
| 33 // DrawingRecorder. |
| 33 DCHECK(RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled() || | 34 DCHECK(RuntimeEnabledFeatures::paintUnderInvalidationCheckingEnabled() || |
| 34 !useCachedDrawingIfPossible(m_context, m_displayItemClient, | 35 !useCachedDrawingIfPossible(m_context, m_displayItemClient, |
| 35 m_displayItemType)); | 36 m_displayItemType)); |
| 36 | 37 |
| 37 DCHECK(DisplayItem::isDrawingType(displayItemType)); | 38 DCHECK(DisplayItem::isDrawingType(displayItemType)); |
| 38 | 39 |
| 39 #if DCHECK_IS_ON() | 40 #if DCHECK_IS_ON() |
| 40 context.setInDrawingRecorder(true); | 41 context.setInDrawingRecorder(true); |
| 41 #endif | 42 #endif |
| 42 | 43 |
| 43 // Use the enclosing int rect, since pixel-snapping may be applied to the boun
ds of the object during painting. Potentially expanding | 44 // Use the enclosing int rect, since pixel-snapping may be applied to the |
| 44 // the cull rect by a pixel or two also does not affect correctness, and is ve
ry unlikely to matter for performance. | 45 // bounds of the object during painting. Potentially expanding the cull rect |
| 46 // by a pixel or two also does not affect correctness, and is very unlikely to |
| 47 // matter for performance. |
| 45 IntRect cullRect = enclosingIntRect(floatCullRect); | 48 IntRect cullRect = enclosingIntRect(floatCullRect); |
| 46 context.beginRecording(cullRect); | 49 context.beginRecording(cullRect); |
| 47 | 50 |
| 48 #if DCHECK_IS_ON() | 51 #if DCHECK_IS_ON() |
| 49 if (RuntimeEnabledFeatures::slimmingPaintStrictCullRectClippingEnabled()) { | 52 if (RuntimeEnabledFeatures::slimmingPaintStrictCullRectClippingEnabled()) { |
| 50 // Skia depends on the cull rect containing all of the display item commands
. When strict | 53 // Skia depends on the cull rect containing all of the display item |
| 51 // cull rect clipping is enabled, make this explicit. This allows us to iden
tify potential | 54 // commands. When strict cull rect clipping is enabled, make this explicit. |
| 52 // incorrect cull rects that might otherwise be masked due to Skia internal
optimizations. | 55 // This allows us to identify potential incorrect cull rects that might |
| 56 // otherwise be masked due to Skia internal optimizations. |
| 53 context.save(); | 57 context.save(); |
| 54 // Expand the verification clip by one pixel to account for Skia's SkCanvas:
:getClipBounds() | 58 // Expand the verification clip by one pixel to account for Skia's |
| 55 // expansion, used in testing cull rects. | 59 // SkCanvas::getClipBounds() expansion, used in testing cull rects. |
| 56 // TODO(schenney) This is not the best place to do this. Ideally, we would e
xpand by one pixel | 60 // TODO(schenney) This is not the best place to do this. Ideally, we would |
| 57 // in device (pixel) space, but to do that we would need to add the verifica
tion mode to Skia. | 61 // expand by one pixel in device (pixel) space, but to do that we would need |
| 62 // to add the verification mode to Skia. |
| 58 cullRect.inflate(1); | 63 cullRect.inflate(1); |
| 59 context.clipRect(cullRect, NotAntiAliased, SkRegion::kIntersect_Op); | 64 context.clipRect(cullRect, NotAntiAliased, SkRegion::kIntersect_Op); |
| 60 } | 65 } |
| 61 #endif | 66 #endif |
| 62 } | 67 } |
| 63 | 68 |
| 64 DrawingRecorder::~DrawingRecorder() { | 69 DrawingRecorder::~DrawingRecorder() { |
| 65 if (m_context.getPaintController().displayItemConstructionIsDisabled()) | 70 if (m_context.getPaintController().displayItemConstructionIsDisabled()) |
| 66 return; | 71 return; |
| 67 | 72 |
| 68 #if DCHECK_IS_ON() | 73 #if DCHECK_IS_ON() |
| 69 if (RuntimeEnabledFeatures::slimmingPaintStrictCullRectClippingEnabled()) | 74 if (RuntimeEnabledFeatures::slimmingPaintStrictCullRectClippingEnabled()) |
| 70 m_context.restore(); | 75 m_context.restore(); |
| 71 | 76 |
| 72 m_context.setInDrawingRecorder(false); | 77 m_context.setInDrawingRecorder(false); |
| 73 DCHECK(m_displayItemPosition == | 78 DCHECK(m_displayItemPosition == |
| 74 m_context.getPaintController().newDisplayItemList().size()); | 79 m_context.getPaintController().newDisplayItemList().size()); |
| 75 #endif | 80 #endif |
| 76 | 81 |
| 77 m_context.getPaintController().createAndAppend<DrawingDisplayItem>( | 82 m_context.getPaintController().createAndAppend<DrawingDisplayItem>( |
| 78 m_displayItemClient, m_displayItemType, m_context.endRecording(), | 83 m_displayItemClient, m_displayItemType, m_context.endRecording(), |
| 79 m_knownToBeOpaque); | 84 m_knownToBeOpaque); |
| 80 } | 85 } |
| 81 | 86 |
| 82 } // namespace blink | 87 } // namespace blink |
| OLD | NEW |