| 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 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 890 return true; | 890 return true; |
| 891 } | 891 } |
| 892 | 892 |
| 893 std::unique_ptr<ImageBufferSurface> | 893 std::unique_ptr<ImageBufferSurface> |
| 894 HTMLCanvasElement::createWebGLImageBufferSurface(OpacityMode opacityMode) { | 894 HTMLCanvasElement::createWebGLImageBufferSurface(OpacityMode opacityMode) { |
| 895 DCHECK(is3D()); | 895 DCHECK(is3D()); |
| 896 // If 3d, but the use of the canvas will be for non-accelerated content | 896 // If 3d, but the use of the canvas will be for non-accelerated content |
| 897 // then make a non-accelerated ImageBuffer. This means copying the internal | 897 // then make a non-accelerated ImageBuffer. This means copying the internal |
| 898 // Image will require a pixel readback, but that is unavoidable in this case. | 898 // Image will require a pixel readback, but that is unavoidable in this case. |
| 899 auto surface = WTF::wrapUnique(new AcceleratedImageBufferSurface( | 899 auto surface = WTF::wrapUnique(new AcceleratedImageBufferSurface( |
| 900 size(), opacityMode, m_context->skColorSpace(), m_context->colorType())); | 900 size(), opacityMode, m_context->skSurfaceColorSpace(), |
| 901 m_context->colorType())); |
| 901 if (surface->isValid()) | 902 if (surface->isValid()) |
| 902 return std::move(surface); | 903 return std::move(surface); |
| 903 return nullptr; | 904 return nullptr; |
| 904 } | 905 } |
| 905 | 906 |
| 906 std::unique_ptr<ImageBufferSurface> | 907 std::unique_ptr<ImageBufferSurface> |
| 907 HTMLCanvasElement::createAcceleratedImageBufferSurface( | 908 HTMLCanvasElement::createAcceleratedImageBufferSurface( |
| 908 OpacityMode opacityMode, | 909 OpacityMode opacityMode, |
| 909 int* msaaSampleCount) { | 910 int* msaaSampleCount) { |
| 910 if (document().settings()) { | 911 if (document().settings()) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 921 CanvasMetrics::Accelerated2DCanvasGPUContextLost); | 922 CanvasMetrics::Accelerated2DCanvasGPUContextLost); |
| 922 return nullptr; | 923 return nullptr; |
| 923 } | 924 } |
| 924 | 925 |
| 925 if (contextProvider->isSoftwareRendering()) | 926 if (contextProvider->isSoftwareRendering()) |
| 926 return nullptr; // Don't use accelerated canvas with swiftshader. | 927 return nullptr; // Don't use accelerated canvas with swiftshader. |
| 927 | 928 |
| 928 std::unique_ptr<ImageBufferSurface> surface = | 929 std::unique_ptr<ImageBufferSurface> surface = |
| 929 WTF::wrapUnique(new Canvas2DImageBufferSurface( | 930 WTF::wrapUnique(new Canvas2DImageBufferSurface( |
| 930 std::move(contextProvider), size(), *msaaSampleCount, opacityMode, | 931 std::move(contextProvider), size(), *msaaSampleCount, opacityMode, |
| 931 Canvas2DLayerBridge::EnableAcceleration, m_context->skColorSpace(), | 932 Canvas2DLayerBridge::EnableAcceleration, m_context->gfxColorSpace(), |
| 932 m_context->colorType())); | 933 m_context->skSurfaceColorSpace(), m_context->colorType())); |
| 933 if (!surface->isValid()) { | 934 if (!surface->isValid()) { |
| 934 CanvasMetrics::countCanvasContextUsage( | 935 CanvasMetrics::countCanvasContextUsage( |
| 935 CanvasMetrics::GPUAccelerated2DCanvasImageBufferCreationFailed); | 936 CanvasMetrics::GPUAccelerated2DCanvasImageBufferCreationFailed); |
| 936 return nullptr; | 937 return nullptr; |
| 937 } | 938 } |
| 938 | 939 |
| 939 CanvasMetrics::countCanvasContextUsage( | 940 CanvasMetrics::countCanvasContextUsage( |
| 940 CanvasMetrics::GPUAccelerated2DCanvasImageBufferCreated); | 941 CanvasMetrics::GPUAccelerated2DCanvasImageBufferCreated); |
| 941 return surface; | 942 return surface; |
| 942 } | 943 } |
| 943 | 944 |
| 944 std::unique_ptr<ImageBufferSurface> | 945 std::unique_ptr<ImageBufferSurface> |
| 945 HTMLCanvasElement::createUnacceleratedImageBufferSurface( | 946 HTMLCanvasElement::createUnacceleratedImageBufferSurface( |
| 946 OpacityMode opacityMode) { | 947 OpacityMode opacityMode) { |
| 947 if (shouldUseDisplayList()) { | 948 if (shouldUseDisplayList()) { |
| 948 auto surface = WTF::wrapUnique(new RecordingImageBufferSurface( | 949 auto surface = WTF::wrapUnique(new RecordingImageBufferSurface( |
| 949 size(), WTF::wrapUnique(new UnacceleratedSurfaceFactory), opacityMode, | 950 size(), WTF::wrapUnique(new UnacceleratedSurfaceFactory), opacityMode, |
| 950 m_context->skColorSpace(), m_context->colorType())); | 951 m_context->skSurfaceColorSpace(), m_context->colorType())); |
| 951 if (surface->isValid()) { | 952 if (surface->isValid()) { |
| 952 CanvasMetrics::countCanvasContextUsage( | 953 CanvasMetrics::countCanvasContextUsage( |
| 953 CanvasMetrics::DisplayList2DCanvasImageBufferCreated); | 954 CanvasMetrics::DisplayList2DCanvasImageBufferCreated); |
| 954 return std::move(surface); | 955 return std::move(surface); |
| 955 } | 956 } |
| 956 // We fallback to a non-display-list surface without recording a metric | 957 // We fallback to a non-display-list surface without recording a metric |
| 957 // here. | 958 // here. |
| 958 } | 959 } |
| 959 | 960 |
| 960 auto surfaceFactory = WTF::makeUnique<UnacceleratedSurfaceFactory>(); | 961 auto surfaceFactory = WTF::makeUnique<UnacceleratedSurfaceFactory>(); |
| 961 auto surface = surfaceFactory->createSurface( | 962 auto surface = surfaceFactory->createSurface(size(), opacityMode, |
| 962 size(), opacityMode, m_context->skColorSpace(), m_context->colorType()); | 963 m_context->skSurfaceColorSpace(), |
| 964 m_context->colorType()); |
| 963 if (surface->isValid()) { | 965 if (surface->isValid()) { |
| 964 CanvasMetrics::countCanvasContextUsage( | 966 CanvasMetrics::countCanvasContextUsage( |
| 965 CanvasMetrics::Unaccelerated2DCanvasImageBufferCreated); | 967 CanvasMetrics::Unaccelerated2DCanvasImageBufferCreated); |
| 966 return surface; | 968 return surface; |
| 967 } | 969 } |
| 968 | 970 |
| 969 CanvasMetrics::countCanvasContextUsage( | 971 CanvasMetrics::countCanvasContextUsage( |
| 970 CanvasMetrics::Unaccelerated2DCanvasImageBufferCreationFailed); | 972 CanvasMetrics::Unaccelerated2DCanvasImageBufferCreationFailed); |
| 971 return nullptr; | 973 return nullptr; |
| 972 } | 974 } |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1437 // Creates a placeholder layer first before Surface is created. | 1439 // Creates a placeholder layer first before Surface is created. |
| 1438 m_surfaceLayerBridge->createSolidColorLayer(); | 1440 m_surfaceLayerBridge->createSolidColorLayer(); |
| 1439 } | 1441 } |
| 1440 } | 1442 } |
| 1441 | 1443 |
| 1442 void HTMLCanvasElement::OnWebLayerReplaced() { | 1444 void HTMLCanvasElement::OnWebLayerReplaced() { |
| 1443 setNeedsCompositingUpdate(); | 1445 setNeedsCompositingUpdate(); |
| 1444 } | 1446 } |
| 1445 | 1447 |
| 1446 } // namespace blink | 1448 } // namespace blink |
| OLD | NEW |