OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 1728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1739 if (enter) { | 1739 if (enter) { |
1740 if (!m_page) | 1740 if (!m_page) |
1741 return; | 1741 return; |
1742 LocalFrame* mainFrame = m_page->mainFrame(); | 1742 LocalFrame* mainFrame = m_page->mainFrame(); |
1743 if (!mainFrame) | 1743 if (!mainFrame) |
1744 return; | 1744 return; |
1745 mainFrame->view()->updateCompositingLayersAfterStyleChange(); | 1745 mainFrame->view()->updateCompositingLayersAfterStyleChange(); |
1746 } | 1746 } |
1747 } | 1747 } |
1748 | 1748 |
1749 void WebViewImpl::doPixelReadbackToCanvas(WebCanvas* canvas, const IntRect& rect
) | 1749 void WebViewImpl::paint(WebCanvas* canvas, const WebRect& rect) |
1750 { | 1750 { |
1751 ASSERT(m_layerTreeView); | 1751 // This should only be used when compositing is not being used for this |
| 1752 // WebView, and it is painting into the recording of its parent. |
| 1753 ASSERT(!isAcceleratedCompositingActive()); |
1752 | 1754 |
1753 SkBitmap target; | 1755 double paintStart = currentTime(); |
1754 target.setConfig(SkImageInfo::MakeN32Premul(rect.width(), rect.height()), re
ct.width() * 4); | 1756 PageWidgetDelegate::paint(m_page.get(), pageOverlays(), canvas, rect, isTran
sparent() ? PageWidgetDelegate::Translucent : PageWidgetDelegate::Opaque); |
1755 if (!target.allocPixels()) | 1757 double paintEnd = currentTime(); |
1756 return; | 1758 double pixelsPerSec = (rect.width * rect.height) / (paintEnd - paintStart); |
1757 m_layerTreeView->compositeAndReadback(target.getPixels(), rect); | 1759 blink::Platform::current()->histogramCustomCounts("Renderer4.SoftwarePaintDu
rationMS", (paintEnd - paintStart) * 1000, 0, 120, 30); |
1758 #if (!SK_R32_SHIFT && SK_B32_SHIFT == 16) | 1760 blink::Platform::current()->histogramCustomCounts("Renderer4.SoftwarePaintMe
gapixPerSecond", pixelsPerSec / 1000000, 10, 210, 30); |
1759 // The compositor readback always gives back pixels in BGRA order, but for | |
1760 // example Android's Skia uses RGBA ordering so the red and blue channels | |
1761 // need to be swapped. | |
1762 uint8_t* pixels = reinterpret_cast<uint8_t*>(target.getPixels()); | |
1763 for (size_t i = 0; i < target.getSize(); i += 4) | |
1764 std::swap(pixels[i], pixels[i + 2]); | |
1765 #endif | |
1766 canvas->writePixels(target, rect.x(), rect.y()); | |
1767 } | |
1768 | |
1769 void WebViewImpl::paint(WebCanvas* canvas, const WebRect& rect, PaintOptions opt
ion) | |
1770 { | |
1771 #if !OS(ANDROID) | |
1772 // ReadbackFromCompositorIfAvailable is the only option available on non-And
roid. | |
1773 // Ideally, Android would always use ReadbackFromCompositorIfAvailable as we
ll. | |
1774 ASSERT(option == ReadbackFromCompositorIfAvailable); | |
1775 #endif | |
1776 | |
1777 if (option == ReadbackFromCompositorIfAvailable && isAcceleratedCompositingA
ctive()) { | |
1778 // If a canvas was passed in, we use it to grab a copy of the | |
1779 // freshly-rendered pixels. | |
1780 if (canvas) { | |
1781 // Clip rect to the confines of the rootLayerTexture. | |
1782 IntRect resizeRect(rect); | |
1783 resizeRect.intersect(IntRect(IntPoint(0, 0), m_layerTreeView->device
ViewportSize())); | |
1784 doPixelReadbackToCanvas(canvas, resizeRect); | |
1785 } | |
1786 } else { | |
1787 FrameView* view = page()->mainFrame()->view(); | |
1788 PaintBehavior oldPaintBehavior = view->paintBehavior(); | |
1789 if (isAcceleratedCompositingActive()) { | |
1790 ASSERT(option == ForceSoftwareRenderingAndIgnoreGPUResidentContent); | |
1791 view->setPaintBehavior(oldPaintBehavior | PaintBehaviorFlattenCompos
itingLayers); | |
1792 } | |
1793 | |
1794 double paintStart = currentTime(); | |
1795 PageWidgetDelegate::paint(m_page.get(), pageOverlays(), canvas, rect, is
Transparent() ? PageWidgetDelegate::Translucent : PageWidgetDelegate::Opaque); | |
1796 double paintEnd = currentTime(); | |
1797 double pixelsPerSec = (rect.width * rect.height) / (paintEnd - paintStar
t); | |
1798 blink::Platform::current()->histogramCustomCounts("Renderer4.SoftwarePai
ntDurationMS", (paintEnd - paintStart) * 1000, 0, 120, 30); | |
1799 blink::Platform::current()->histogramCustomCounts("Renderer4.SoftwarePai
ntMegapixPerSecond", pixelsPerSec / 1000000, 10, 210, 30); | |
1800 | |
1801 if (isAcceleratedCompositingActive()) { | |
1802 ASSERT(option == ForceSoftwareRenderingAndIgnoreGPUResidentContent); | |
1803 view->setPaintBehavior(oldPaintBehavior); | |
1804 } | |
1805 } | |
1806 } | 1761 } |
1807 | 1762 |
1808 #if OS(ANDROID) | 1763 #if OS(ANDROID) |
1809 void WebViewImpl::paintCompositedDeprecated(WebCanvas* canvas, const WebRect& re
ct) | 1764 void WebViewImpl::paintCompositedDeprecated(WebCanvas* canvas, const WebRect& re
ct) |
1810 { | 1765 { |
1811 // Note: This method exists on OS(ANDROID) and will hopefully be | 1766 // Note: This method exists on OS(ANDROID) and will hopefully be |
1812 // removed once the link disambiguation feature renders using | 1767 // removed once the link disambiguation feature renders using |
1813 // the compositor. | 1768 // the compositor. |
1814 ASSERT(isAcceleratedCompositingActive()); | 1769 ASSERT(isAcceleratedCompositingActive()); |
1815 | 1770 |
(...skipping 2293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4109 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi
nedConstraints(); | 4064 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi
nedConstraints(); |
4110 | 4065 |
4111 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) | 4066 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) |
4112 return false; | 4067 return false; |
4113 | 4068 |
4114 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width | 4069 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width |
4115 || (constraints.minimumScale == constraints.maximumScale && constraints.
minimumScale != -1); | 4070 || (constraints.minimumScale == constraints.maximumScale && constraints.
minimumScale != -1); |
4116 } | 4071 } |
4117 | 4072 |
4118 } // namespace blink | 4073 } // namespace blink |
OLD | NEW |