| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> | 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> |
| 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. | 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 747 // Image will require a pixel readback, but that is unavoidable in this
case. | 747 // Image will require a pixel readback, but that is unavoidable in this
case. |
| 748 return adoptPtr(new AcceleratedImageBufferSurface(deviceSize, opacityMod
e)); | 748 return adoptPtr(new AcceleratedImageBufferSurface(deviceSize, opacityMod
e)); |
| 749 } | 749 } |
| 750 | 750 |
| 751 if (shouldAccelerate(deviceSize)) { | 751 if (shouldAccelerate(deviceSize)) { |
| 752 if (document().settings()) | 752 if (document().settings()) |
| 753 *msaaSampleCount = document().settings()->accelerated2dCanvasMSAASam
pleCount(); | 753 *msaaSampleCount = document().settings()->accelerated2dCanvasMSAASam
pleCount(); |
| 754 OwnPtr<ImageBufferSurface> surface = adoptPtr(new Canvas2DImageBufferSur
face(deviceSize, *msaaSampleCount, opacityMode, Canvas2DLayerBridge::EnableAccel
eration)); | 754 OwnPtr<ImageBufferSurface> surface = adoptPtr(new Canvas2DImageBufferSur
face(deviceSize, *msaaSampleCount, opacityMode, Canvas2DLayerBridge::EnableAccel
eration)); |
| 755 if (surface->isValid()) { | 755 if (surface->isValid()) { |
| 756 CanvasMetrics::countCanvasContextUsage(CanvasMetrics::GPUAccelerated
2DCanvasImageBufferCreated); | 756 CanvasMetrics::countCanvasContextUsage(CanvasMetrics::GPUAccelerated
2DCanvasImageBufferCreated); |
| 757 return surface.release(); | 757 return surface; |
| 758 } | 758 } |
| 759 CanvasMetrics::countCanvasContextUsage(CanvasMetrics::GPUAccelerated2DCa
nvasImageBufferCreationFailed); | 759 CanvasMetrics::countCanvasContextUsage(CanvasMetrics::GPUAccelerated2DCa
nvasImageBufferCreationFailed); |
| 760 } | 760 } |
| 761 | 761 |
| 762 OwnPtr<RecordingImageBufferFallbackSurfaceFactory> surfaceFactory = adoptPtr
(new UnacceleratedSurfaceFactory()); | 762 OwnPtr<RecordingImageBufferFallbackSurfaceFactory> surfaceFactory = adoptPtr
(new UnacceleratedSurfaceFactory()); |
| 763 | 763 |
| 764 if (shouldUseDisplayList(deviceSize)) { | 764 if (shouldUseDisplayList(deviceSize)) { |
| 765 OwnPtr<ImageBufferSurface> surface = adoptPtr(new RecordingImageBufferSu
rface(deviceSize, surfaceFactory.release(), opacityMode)); | 765 OwnPtr<ImageBufferSurface> surface = adoptPtr(new RecordingImageBufferSu
rface(deviceSize, std::move(surfaceFactory), opacityMode)); |
| 766 if (surface->isValid()) { | 766 if (surface->isValid()) { |
| 767 CanvasMetrics::countCanvasContextUsage(CanvasMetrics::DisplayList2DC
anvasImageBufferCreated); | 767 CanvasMetrics::countCanvasContextUsage(CanvasMetrics::DisplayList2DC
anvasImageBufferCreated); |
| 768 return surface.release(); | 768 return surface; |
| 769 } | 769 } |
| 770 surfaceFactory = adoptPtr(new UnacceleratedSurfaceFactory()); // recreat
e because previous one was released | 770 surfaceFactory = adoptPtr(new UnacceleratedSurfaceFactory()); // recreat
e because previous one was released |
| 771 } | 771 } |
| 772 auto surface = surfaceFactory->createSurface(deviceSize, opacityMode); | 772 auto surface = surfaceFactory->createSurface(deviceSize, opacityMode); |
| 773 if (!surface->isValid()) { | 773 if (!surface->isValid()) { |
| 774 CanvasMetrics::countCanvasContextUsage(CanvasMetrics::Unaccelerated2DCan
vasImageBufferCreationFailed); | 774 CanvasMetrics::countCanvasContextUsage(CanvasMetrics::Unaccelerated2DCan
vasImageBufferCreationFailed); |
| 775 } else { | 775 } else { |
| 776 CanvasMetrics::countCanvasContextUsage(CanvasMetrics::Unaccelerated2DCan
vasImageBufferCreated); | 776 CanvasMetrics::countCanvasContextUsage(CanvasMetrics::Unaccelerated2DCan
vasImageBufferCreated); |
| 777 } | 777 } |
| 778 return surface; | 778 return surface; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 795 if (!canCreateImageBuffer(size())) | 795 if (!canCreateImageBuffer(size())) |
| 796 return; | 796 return; |
| 797 | 797 |
| 798 int msaaSampleCount = 0; | 798 int msaaSampleCount = 0; |
| 799 OwnPtr<ImageBufferSurface> surface; | 799 OwnPtr<ImageBufferSurface> surface; |
| 800 if (externalSurface) { | 800 if (externalSurface) { |
| 801 surface = std::move(externalSurface); | 801 surface = std::move(externalSurface); |
| 802 } else { | 802 } else { |
| 803 surface = createImageBufferSurface(size(), &msaaSampleCount); | 803 surface = createImageBufferSurface(size(), &msaaSampleCount); |
| 804 } | 804 } |
| 805 m_imageBuffer = ImageBuffer::create(surface.release()); | 805 m_imageBuffer = ImageBuffer::create(std::move(surface)); |
| 806 if (!m_imageBuffer) | 806 if (!m_imageBuffer) |
| 807 return; | 807 return; |
| 808 m_imageBuffer->setClient(this); | 808 m_imageBuffer->setClient(this); |
| 809 | 809 |
| 810 m_didFailToCreateImageBuffer = false; | 810 m_didFailToCreateImageBuffer = false; |
| 811 | 811 |
| 812 updateExternallyAllocatedMemory(); | 812 updateExternallyAllocatedMemory(); |
| 813 | 813 |
| 814 if (is3D()) { | 814 if (is3D()) { |
| 815 // Early out for WebGL canvases | 815 // Early out for WebGL canvases |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1124 } | 1124 } |
| 1125 | 1125 |
| 1126 String HTMLCanvasElement::getIdFromControl(const Element* element) | 1126 String HTMLCanvasElement::getIdFromControl(const Element* element) |
| 1127 { | 1127 { |
| 1128 if (m_context) | 1128 if (m_context) |
| 1129 return m_context->getIdFromControl(element); | 1129 return m_context->getIdFromControl(element); |
| 1130 return String(); | 1130 return String(); |
| 1131 } | 1131 } |
| 1132 | 1132 |
| 1133 } // namespace blink | 1133 } // namespace blink |
| OLD | NEW |