| 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 "config.h" | 5 #include "config.h" |
| 6 #include "platform/graphics/paint/DrawingRecorder.h" | 6 #include "platform/graphics/paint/DrawingRecorder.h" |
| 7 | 7 |
| 8 #include "platform/RuntimeEnabledFeatures.h" | 8 #include "platform/RuntimeEnabledFeatures.h" |
| 9 #include "platform/graphics/GraphicsContext.h" | 9 #include "platform/graphics/GraphicsContext.h" |
| 10 #include "platform/graphics/GraphicsLayer.h" | 10 #include "platform/graphics/GraphicsLayer.h" |
| 11 #include "platform/graphics/paint/CachedDisplayItem.h" | 11 #include "platform/graphics/paint/CachedDisplayItem.h" |
| 12 #include "platform/graphics/paint/DisplayItemList.h" | 12 #include "platform/graphics/paint/DisplayItemList.h" |
| 13 #include "platform/graphics/paint/DrawingDisplayItem.h" | 13 #include "platform/graphics/paint/DrawingDisplayItem.h" |
| 14 #include "third_party/skia/include/core/SkPicture.h" | 14 #include "third_party/skia/include/core/SkPicture.h" |
| 15 | 15 |
| 16 namespace blink { | 16 namespace blink { |
| 17 | 17 |
| 18 DrawingRecorder::DrawingRecorder(GraphicsContext* context, const DisplayItemClie
nt displayItemClient, DisplayItem::Type displayItemType, const FloatRect& bounds
) | 18 DrawingRecorder::DrawingRecorder(GraphicsContext* context, const DisplayItemClie
nt displayItemClient, DisplayItem::Type displayItemType, const FloatRect& bounds
) |
| 19 : m_context(context) | 19 : m_context(context) |
| 20 , m_displayItemClient(displayItemClient) | 20 , m_displayItemClient(displayItemClient) |
| 21 , m_displayItemType(displayItemType) | 21 , m_displayItemType(displayItemType) |
| 22 , m_canUseCachedDrawing(false) |
| 23 #ifndef NDEBUG |
| 22 , m_bounds(bounds) | 24 , m_bounds(bounds) |
| 23 , m_canUseCachedDrawing(false) | 25 #endif |
| 24 { | 26 { |
| 25 if (!RuntimeEnabledFeatures::slimmingPaintEnabled()) | 27 if (!RuntimeEnabledFeatures::slimmingPaintEnabled()) |
| 26 return; | 28 return; |
| 27 | 29 |
| 28 #if ENABLE(ASSERT) | 30 #if ENABLE(ASSERT) |
| 29 context->setInDrawingRecorder(true); | 31 context->setInDrawingRecorder(true); |
| 30 #endif | 32 #endif |
| 31 ASSERT(context->displayItemList()); | 33 ASSERT(context->displayItemList()); |
| 32 m_canUseCachedDrawing = context->displayItemList()->clientCacheIsValid(displ
ayItemClient); | 34 m_canUseCachedDrawing = context->displayItemList()->clientCacheIsValid(displ
ayItemClient); |
| 33 #if ENABLE(ASSERT) | 35 #if ENABLE(ASSERT) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 48 m_context->setInDrawingRecorder(false); | 50 m_context->setInDrawingRecorder(false); |
| 49 #endif | 51 #endif |
| 50 | 52 |
| 51 OwnPtr<DisplayItem> displayItem; | 53 OwnPtr<DisplayItem> displayItem; |
| 52 | 54 |
| 53 if (m_canUseCachedDrawing) { | 55 if (m_canUseCachedDrawing) { |
| 54 #if ENABLE(ASSERT) | 56 #if ENABLE(ASSERT) |
| 55 RefPtr<const SkPicture> picture = m_context->endRecording(); | 57 RefPtr<const SkPicture> picture = m_context->endRecording(); |
| 56 ASSERT(!picture || !picture->approximateOpCount()); | 58 ASSERT(!picture || !picture->approximateOpCount()); |
| 57 #endif | 59 #endif |
| 60 #ifdef NDEBUG |
| 58 displayItem = CachedDisplayItem::create(m_displayItemClient, m_displayIt
emType); | 61 displayItem = CachedDisplayItem::create(m_displayItemClient, m_displayIt
emType); |
| 62 #else |
| 63 displayItem = CachedDisplayItem::create(m_displayItemClient, m_displayIt
emType, m_bounds); |
| 64 #endif |
| 59 } else { | 65 } else { |
| 60 RefPtr<const SkPicture> picture = m_context->endRecording(); | 66 RefPtr<const SkPicture> picture = m_context->endRecording(); |
| 61 if (!picture || !picture->approximateOpCount()) | 67 if (!picture || !picture->approximateOpCount()) |
| 62 displayItem = DisplayItem::create(m_displayItemClient, m_displayItem
Type); | 68 displayItem = DisplayItem::create(m_displayItemClient, m_displayItem
Type); |
| 63 else | 69 else |
| 64 displayItem = DrawingDisplayItem::create(m_displayItemClient, m_disp
layItemType, picture); | 70 displayItem = DrawingDisplayItem::create(m_displayItemClient, m_disp
layItemType, picture); |
| 65 } | 71 } |
| 66 | 72 |
| 67 #ifndef NDEBUG | 73 #ifndef NDEBUG |
| 68 displayItem->setClientDebugString(m_clientDebugString); | 74 displayItem->setClientDebugString(m_clientDebugString); |
| 69 #endif | 75 #endif |
| 70 | 76 |
| 71 m_context->displayItemList()->add(displayItem.release()); | 77 m_context->displayItemList()->add(displayItem.release()); |
| 72 } | 78 } |
| 73 | 79 |
| 74 #ifndef NDEBUG | 80 #ifndef NDEBUG |
| 75 void DrawingRecorder::setClientDebugString(const WTF::String& clientDebugString) | 81 void DrawingRecorder::setClientDebugString(const WTF::String& clientDebugString) |
| 76 { | 82 { |
| 77 m_clientDebugString = clientDebugString; | 83 m_clientDebugString = clientDebugString; |
| 78 } | 84 } |
| 79 #endif | 85 #endif |
| 80 | 86 |
| 81 } // namespace blink | 87 } // namespace blink |
| OLD | NEW |