| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "platform/TraceEvent.h" | 31 #include "platform/TraceEvent.h" |
| 32 #include "platform/TracedValue.h" | 32 #include "platform/TracedValue.h" |
| 33 #include "platform/geometry/IntRect.h" | 33 #include "platform/geometry/IntRect.h" |
| 34 #include "platform/graphics/GraphicsContext.h" | 34 #include "platform/graphics/GraphicsContext.h" |
| 35 #include "platform/graphics/paint/PaintArtifactToSkCanvas.h" | 35 #include "platform/graphics/paint/PaintArtifactToSkCanvas.h" |
| 36 #include "platform/graphics/paint/PaintController.h" | 36 #include "platform/graphics/paint/PaintController.h" |
| 37 #include "platform/transforms/AffineTransform.h" | 37 #include "platform/transforms/AffineTransform.h" |
| 38 #include "platform/transforms/TransformationMatrix.h" | 38 #include "platform/transforms/TransformationMatrix.h" |
| 39 #include "public/platform/WebDisplayItemList.h" | 39 #include "public/platform/WebDisplayItemList.h" |
| 40 #include "public/platform/WebFloatRect.h" | 40 #include "public/platform/WebFloatRect.h" |
| 41 #include "public/platform/WebRect.h" | |
| 42 #include "third_party/skia/include/core/SkCanvas.h" | 41 #include "third_party/skia/include/core/SkCanvas.h" |
| 43 #include "third_party/skia/include/core/SkPicture.h" | 42 #include "third_party/skia/include/core/SkPicture.h" |
| 44 #include "ui/gfx/geometry/rect.h" | 43 #include "ui/gfx/geometry/rect.h" |
| 45 | 44 |
| 46 namespace blink { | 45 namespace blink { |
| 47 | 46 |
| 48 ContentLayerDelegate::ContentLayerDelegate(GraphicsContextPainter* painter) | 47 ContentLayerDelegate::ContentLayerDelegate(GraphicsContextPainter* painter) |
| 49 : m_painter(painter) | 48 : m_painter(painter) |
| 50 { | 49 { |
| 51 } | 50 } |
| 52 | 51 |
| 53 ContentLayerDelegate::~ContentLayerDelegate() | 52 ContentLayerDelegate::~ContentLayerDelegate() |
| 54 { | 53 { |
| 55 } | 54 } |
| 56 | 55 |
| 57 PassRefPtr<TracedValue> toTracedValue(const WebRect& clip) | 56 static void paintArtifactToWebDisplayItemList(WebDisplayItemList* list, const Pa
intArtifact& artifact, const gfx::Rect& bounds) |
| 58 { | |
| 59 RefPtr<TracedValue> tracedValue = TracedValue::create(); | |
| 60 tracedValue->beginArray("clip_rect"); | |
| 61 tracedValue->pushInteger(clip.x); | |
| 62 tracedValue->pushInteger(clip.y); | |
| 63 tracedValue->pushInteger(clip.width); | |
| 64 tracedValue->pushInteger(clip.height); | |
| 65 tracedValue->endArray(); | |
| 66 return tracedValue; | |
| 67 } | |
| 68 | |
| 69 static void paintArtifactToWebDisplayItemList(WebDisplayItemList* list, const Pa
intArtifact& artifact, const WebRect& bounds) | |
| 70 { | 57 { |
| 71 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { | 58 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) { |
| 72 // This is a temporary path to paint the artifact using the paint chunk | 59 // This is a temporary path to paint the artifact using the paint chunk |
| 73 // properties. Ultimately, we should instead split the artifact into | 60 // properties. Ultimately, we should instead split the artifact into |
| 74 // separate layers and send those to the compositor, instead of sending | 61 // separate layers and send those to the compositor, instead of sending |
| 75 // one big flat SkPicture. | 62 // one big flat SkPicture. |
| 76 SkRect skBounds = SkRect::MakeXYWH(bounds.x, bounds.y, bounds.width, bou
nds.height); | 63 SkRect skBounds = SkRect::MakeXYWH(bounds.x(), bounds.y(), bounds.width(
), bounds.height()); |
| 77 RefPtr<SkPicture> picture = paintArtifactToSkPicture(artifact, skBounds)
; | 64 RefPtr<SkPicture> picture = paintArtifactToSkPicture(artifact, skBounds)
; |
| 78 // TODO(wkorman): Pass actual visual rect with the drawing item. | 65 // TODO(wkorman): Pass actual visual rect with the drawing item. |
| 79 list->appendDrawingItem(IntRect(), picture.get()); | 66 list->appendDrawingItem(IntRect(), picture.get()); |
| 80 return; | 67 return; |
| 81 } | 68 } |
| 82 artifact.appendToWebDisplayItemList(list); | 69 artifact.appendToWebDisplayItemList(list); |
| 83 } | 70 } |
| 84 | 71 |
| 85 gfx::Rect ContentLayerDelegate::paintableRegion() | 72 gfx::Rect ContentLayerDelegate::paintableRegion() |
| 86 { | 73 { |
| 87 IntRect interestRect = m_painter->interestRect(); | 74 IntRect interestRect = m_painter->interestRect(); |
| 88 return gfx::Rect(interestRect.x(), interestRect.y(), interestRect.width(), i
nterestRect.height()); | 75 return gfx::Rect(interestRect.x(), interestRect.y(), interestRect.width(), i
nterestRect.height()); |
| 89 } | 76 } |
| 90 | 77 |
| 91 void ContentLayerDelegate::paintContents( | 78 void ContentLayerDelegate::paintContents( |
| 92 WebDisplayItemList* webDisplayItemList, const WebRect& clip, | 79 WebDisplayItemList* webDisplayItemList, WebContentLayerClient::PaintingContr
olSetting paintingControl) |
| 93 WebContentLayerClient::PaintingControlSetting paintingControl) | |
| 94 { | 80 { |
| 95 TRACE_EVENT1("blink,benchmark", "ContentLayerDelegate::paintContents", "clip
_rect", toTracedValue(clip)); | 81 TRACE_EVENT0("blink,benchmark", "ContentLayerDelegate::paintContents"); |
| 96 | 82 |
| 97 PaintController* paintController = m_painter->paintController(); | 83 PaintController* paintController = m_painter->paintController(); |
| 98 ASSERT(paintController); | 84 ASSERT(paintController); |
| 99 paintController->setDisplayItemConstructionIsDisabled( | 85 paintController->setDisplayItemConstructionIsDisabled( |
| 100 paintingControl == WebContentLayerClient::DisplayListConstructionDisable
d); | 86 paintingControl == WebContentLayerClient::DisplayListConstructionDisable
d); |
| 101 | 87 |
| 102 // We also disable caching when Painting or Construction are disabled. In bo
th cases we would like | 88 // We also disable caching when Painting or Construction are disabled. In bo
th cases we would like |
| 103 // to compare assuming the full cost of recording, not the cost of re-using
cached content. | 89 // to compare assuming the full cost of recording, not the cost of re-using
cached content. |
| 104 if (paintingControl != WebContentLayerClient::PaintDefaultBehavior) | 90 if (paintingControl != WebContentLayerClient::PaintDefaultBehavior) |
| 105 paintController->invalidateAll(); | 91 paintController->invalidateAll(); |
| 106 | 92 |
| 107 GraphicsContext::DisabledMode disabledMode = GraphicsContext::NothingDisable
d; | 93 GraphicsContext::DisabledMode disabledMode = GraphicsContext::NothingDisable
d; |
| 108 if (paintingControl == WebContentLayerClient::DisplayListPaintingDisabled | 94 if (paintingControl == WebContentLayerClient::DisplayListPaintingDisabled |
| 109 || paintingControl == WebContentLayerClient::DisplayListConstructionDisa
bled) | 95 || paintingControl == WebContentLayerClient::DisplayListConstructionDisa
bled) |
| 110 disabledMode = GraphicsContext::FullyDisabled; | 96 disabledMode = GraphicsContext::FullyDisabled; |
| 111 GraphicsContext context(*paintController, disabledMode); | 97 GraphicsContext context(*paintController, disabledMode); |
| 112 | 98 |
| 113 IntRect interestRect = clip; | 99 m_painter->paint(context, nullptr); |
| 114 m_painter->paint(context, &interestRect); | |
| 115 | 100 |
| 116 paintController->commitNewDisplayItems(); | 101 paintController->commitNewDisplayItems(); |
| 117 paintArtifactToWebDisplayItemList(webDisplayItemList, paintController->paint
Artifact(), clip); | 102 paintArtifactToWebDisplayItemList(webDisplayItemList, paintController->paint
Artifact(), paintableRegion()); |
| 118 paintController->setDisplayItemConstructionIsDisabled(false); | 103 paintController->setDisplayItemConstructionIsDisabled(false); |
| 119 } | 104 } |
| 120 | 105 |
| 121 size_t ContentLayerDelegate::approximateUnsharedMemoryUsage() const | 106 size_t ContentLayerDelegate::approximateUnsharedMemoryUsage() const |
| 122 { | 107 { |
| 123 return m_painter->paintController()->approximateUnsharedMemoryUsage(); | 108 return m_painter->paintController()->approximateUnsharedMemoryUsage(); |
| 124 } | 109 } |
| 125 | 110 |
| 126 } // namespace blink | 111 } // namespace blink |
| OLD | NEW |