Chromium Code Reviews| 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 1749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1760 // The compositor readback always gives back pixels in BGRA order, but for | 1760 // The compositor readback always gives back pixels in BGRA order, but for |
| 1761 // example Android's Skia uses RGBA ordering so the red and blue channels | 1761 // example Android's Skia uses RGBA ordering so the red and blue channels |
| 1762 // need to be swapped. | 1762 // need to be swapped. |
| 1763 uint8_t* pixels = reinterpret_cast<uint8_t*>(target.getPixels()); | 1763 uint8_t* pixels = reinterpret_cast<uint8_t*>(target.getPixels()); |
| 1764 for (size_t i = 0; i < target.getSize(); i += 4) | 1764 for (size_t i = 0; i < target.getSize(); i += 4) |
| 1765 std::swap(pixels[i], pixels[i + 2]); | 1765 std::swap(pixels[i], pixels[i + 2]); |
| 1766 #endif | 1766 #endif |
| 1767 canvas->writePixels(target, rect.x(), rect.y()); | 1767 canvas->writePixels(target, rect.x(), rect.y()); |
| 1768 } | 1768 } |
| 1769 | 1769 |
| 1770 void WebViewImpl::paint(WebCanvas* canvas, const WebRect& rect, PaintOptions opt ion) | 1770 void WebViewImpl::paint(WebCanvas* canvas, const WebRect& rect) |
|
enne (OOO)
2014/05/02 23:16:23
I do think this needs to be split into two functio
| |
| 1771 { | 1771 { |
| 1772 // Note: This method can be called on a composited WebView on OS(ANDROID) | |
| 1773 // but this will hopefully be changed once the link disambiguation feature | |
| 1774 // renders using the compositor. | |
| 1772 #if !OS(ANDROID) | 1775 #if !OS(ANDROID) |
| 1773 // ReadbackFromCompositorIfAvailable is the only option available on non-And roid. | 1776 // This should only be used when compositing is not being used for this |
| 1774 // Ideally, Android would always use ReadbackFromCompositorIfAvailable as we ll. | 1777 // WebView, and it is painting into the recording of its parent. |
| 1775 ASSERT(option == ReadbackFromCompositorIfAvailable); | 1778 ASSERT(!isAcceleratedCompositingActive()); |
| 1776 #endif | 1779 #endif |
| 1777 | 1780 |
| 1778 if (option == ReadbackFromCompositorIfAvailable && isAcceleratedCompositingA ctive()) { | 1781 FrameView* view = page()->mainFrame()->view(); |
| 1779 // If a canvas was passed in, we use it to grab a copy of the | 1782 PaintBehavior oldPaintBehavior = view->paintBehavior(); |
| 1780 // freshly-rendered pixels. | |
| 1781 if (canvas) { | |
| 1782 // Clip rect to the confines of the rootLayerTexture. | |
| 1783 IntRect resizeRect(rect); | |
| 1784 resizeRect.intersect(IntRect(IntPoint(0, 0), m_layerTreeView->device ViewportSize())); | |
| 1785 doPixelReadbackToCanvas(canvas, resizeRect); | |
| 1786 } | |
| 1787 } else { | |
| 1788 FrameView* view = page()->mainFrame()->view(); | |
| 1789 PaintBehavior oldPaintBehavior = view->paintBehavior(); | |
| 1790 if (isAcceleratedCompositingActive()) { | |
| 1791 ASSERT(option == ForceSoftwareRenderingAndIgnoreGPUResidentContent); | |
| 1792 view->setPaintBehavior(oldPaintBehavior | PaintBehaviorFlattenCompos itingLayers); | |
| 1793 } | |
| 1794 | 1783 |
| 1795 double paintStart = currentTime(); | 1784 double paintStart = currentTime(); |
| 1796 PageWidgetDelegate::paint(m_page.get(), pageOverlays(), canvas, rect, is Transparent() ? PageWidgetDelegate::Translucent : PageWidgetDelegate::Opaque); | |
| 1797 double paintEnd = currentTime(); | |
| 1798 double pixelsPerSec = (rect.width * rect.height) / (paintEnd - paintStar t); | |
| 1799 blink::Platform::current()->histogramCustomCounts("Renderer4.SoftwarePai ntDurationMS", (paintEnd - paintStart) * 1000, 0, 120, 30); | |
| 1800 blink::Platform::current()->histogramCustomCounts("Renderer4.SoftwarePai ntMegapixPerSecond", pixelsPerSec / 1000000, 10, 210, 30); | |
| 1801 | 1785 |
| 1802 if (isAcceleratedCompositingActive()) { | 1786 #if OS(ANDROID) |
|
danakj
2014/05/02 23:12:53
This OS(ANDROID) stuff is a disaster.
abarth: WDY
| |
| 1803 ASSERT(option == ForceSoftwareRenderingAndIgnoreGPUResidentContent); | 1787 if (isAcceleratedCompositingActive()) |
| 1804 view->setPaintBehavior(oldPaintBehavior); | 1788 view->setPaintBehavior(oldPaintBehavior | PaintBehaviorFlattenCompositin gLayers); |
| 1805 } | 1789 #endif |
| 1806 } | 1790 |
| 1791 PageWidgetDelegate::paint(m_page.get(), pageOverlays(), canvas, rect, isTran sparent() ? PageWidgetDelegate::Translucent : PageWidgetDelegate::Opaque); | |
| 1792 | |
| 1793 #if OS(ANDROID) | |
| 1794 if (isAcceleratedCompositingActive()) | |
| 1795 view->setPaintBehavior(oldPaintBehavior); | |
| 1796 #endif | |
| 1797 | |
| 1798 double paintEnd = currentTime(); | |
| 1799 double pixelsPerSec = (rect.width * rect.height) / (paintEnd - paintStart); | |
| 1800 blink::Platform::current()->histogramCustomCounts("Renderer4.SoftwarePaintDu rationMS", (paintEnd - paintStart) * 1000, 0, 120, 30); | |
| 1801 blink::Platform::current()->histogramCustomCounts("Renderer4.SoftwarePaintMe gapixPerSecond", pixelsPerSec / 1000000, 10, 210, 30); | |
| 1807 } | 1802 } |
| 1808 | 1803 |
| 1809 bool WebViewImpl::compositeAndReadbackAsync(WebCompositeAndReadbackAsyncCallback * callback) | 1804 bool WebViewImpl::compositeAndReadbackAsync(WebCompositeAndReadbackAsyncCallback * callback) |
| 1810 { | 1805 { |
| 1811 if (!isAcceleratedCompositingActive()) | 1806 if (!isAcceleratedCompositingActive()) |
| 1812 return false; | 1807 return false; |
| 1813 m_layerTreeView->compositeAndReadbackAsync(callback); | 1808 m_layerTreeView->compositeAndReadbackAsync(callback); |
| 1814 return true; | 1809 return true; |
| 1815 } | 1810 } |
| 1816 | 1811 |
| (...skipping 2269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4086 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); | 4081 const PageScaleConstraints& constraints = m_pageScaleConstraintsSet.pageDefi nedConstraints(); |
| 4087 | 4082 |
| 4088 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) | 4083 if (!mainFrameImpl() || !mainFrameImpl()->frameView()) |
| 4089 return false; | 4084 return false; |
| 4090 | 4085 |
| 4091 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width | 4086 return mainFrameImpl()->frameView()->layoutSize().width() == m_size.width |
| 4092 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); | 4087 || (constraints.minimumScale == constraints.maximumScale && constraints. minimumScale != -1); |
| 4093 } | 4088 } |
| 4094 | 4089 |
| 4095 } // namespace blink | 4090 } // namespace blink |
| OLD | NEW |