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