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 30 matching lines...) Expand all Loading... | |
41 #include "core/html/canvas/CanvasAsyncBlobCreator.h" | 41 #include "core/html/canvas/CanvasAsyncBlobCreator.h" |
42 #include "core/html/canvas/CanvasContextCreationAttributes.h" | 42 #include "core/html/canvas/CanvasContextCreationAttributes.h" |
43 #include "core/html/canvas/CanvasFontCache.h" | 43 #include "core/html/canvas/CanvasFontCache.h" |
44 #include "core/html/canvas/CanvasRenderingContext.h" | 44 #include "core/html/canvas/CanvasRenderingContext.h" |
45 #include "core/html/canvas/CanvasRenderingContextFactory.h" | 45 #include "core/html/canvas/CanvasRenderingContextFactory.h" |
46 #include "core/layout/LayoutHTMLCanvas.h" | 46 #include "core/layout/LayoutHTMLCanvas.h" |
47 #include "core/paint/PaintLayer.h" | 47 #include "core/paint/PaintLayer.h" |
48 #include "platform/MIMETypeRegistry.h" | 48 #include "platform/MIMETypeRegistry.h" |
49 #include "platform/RuntimeEnabledFeatures.h" | 49 #include "platform/RuntimeEnabledFeatures.h" |
50 #include "platform/graphics/Canvas2DImageBufferSurface.h" | 50 #include "platform/graphics/Canvas2DImageBufferSurface.h" |
51 #include "platform/graphics/CanvasMetrics.h" | |
51 #include "platform/graphics/ExpensiveCanvasHeuristicParameters.h" | 52 #include "platform/graphics/ExpensiveCanvasHeuristicParameters.h" |
52 #include "platform/graphics/ImageBuffer.h" | 53 #include "platform/graphics/ImageBuffer.h" |
53 #include "platform/graphics/RecordingImageBufferSurface.h" | 54 #include "platform/graphics/RecordingImageBufferSurface.h" |
54 #include "platform/graphics/StaticBitmapImage.h" | 55 #include "platform/graphics/StaticBitmapImage.h" |
55 #include "platform/graphics/UnacceleratedImageBufferSurface.h" | 56 #include "platform/graphics/UnacceleratedImageBufferSurface.h" |
56 #include "platform/graphics/gpu/AcceleratedImageBufferSurface.h" | 57 #include "platform/graphics/gpu/AcceleratedImageBufferSurface.h" |
57 #include "platform/transforms/AffineTransform.h" | 58 #include "platform/transforms/AffineTransform.h" |
58 #include "public/platform/Platform.h" | 59 #include "public/platform/Platform.h" |
59 #include "public/platform/WebTraceLocation.h" | 60 #include "public/platform/WebTraceLocation.h" |
60 #include <math.h> | 61 #include <math.h> |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 : HTMLElement(canvasTag, document) | 111 : HTMLElement(canvasTag, document) |
111 , DocumentVisibilityObserver(document) | 112 , DocumentVisibilityObserver(document) |
112 , m_size(DefaultWidth, DefaultHeight) | 113 , m_size(DefaultWidth, DefaultHeight) |
113 , m_ignoreReset(false) | 114 , m_ignoreReset(false) |
114 , m_externallyAllocatedMemory(0) | 115 , m_externallyAllocatedMemory(0) |
115 , m_originClean(true) | 116 , m_originClean(true) |
116 , m_didFailToCreateImageBuffer(false) | 117 , m_didFailToCreateImageBuffer(false) |
117 , m_imageBufferIsClear(false) | 118 , m_imageBufferIsClear(false) |
118 { | 119 { |
119 setHasCustomStyleCallbacks(); | 120 setHasCustomStyleCallbacks(); |
121 CanvasMetrics::countCanvasContextStat(CanvasMetrics::ContextCreated); | |
Justin Novosad
2015/11/19 20:36:08
ContextCreated -> CanvasCreated
zmin
2015/11/19 22:23:36
Done.
| |
120 } | 122 } |
121 | 123 |
122 DEFINE_NODE_FACTORY(HTMLCanvasElement) | 124 DEFINE_NODE_FACTORY(HTMLCanvasElement) |
123 | 125 |
124 HTMLCanvasElement::~HTMLCanvasElement() | 126 HTMLCanvasElement::~HTMLCanvasElement() |
125 { | 127 { |
126 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-m_external lyAllocatedMemory); | 128 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-m_external lyAllocatedMemory); |
127 #if !ENABLE(OILPAN) | 129 #if !ENABLE(OILPAN) |
128 // Ensure these go away before the ImageBuffer. | 130 // Ensure these go away before the ImageBuffer. |
129 m_context.clear(); | 131 m_context.clear(); |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
646 // If 3d, but the use of the canvas will be for non-accelerated content | 648 // If 3d, but the use of the canvas will be for non-accelerated content |
647 // then make a non-accelerated ImageBuffer. This means copying the inter nal | 649 // then make a non-accelerated ImageBuffer. This means copying the inter nal |
648 // Image will require a pixel readback, but that is unavoidable in this case. | 650 // Image will require a pixel readback, but that is unavoidable in this case. |
649 return adoptPtr(new AcceleratedImageBufferSurface(deviceSize, opacityMod e)); | 651 return adoptPtr(new AcceleratedImageBufferSurface(deviceSize, opacityMod e)); |
650 } | 652 } |
651 | 653 |
652 if (shouldAccelerate(deviceSize)) { | 654 if (shouldAccelerate(deviceSize)) { |
653 if (document().settings()) | 655 if (document().settings()) |
654 *msaaSampleCount = document().settings()->accelerated2dCanvasMSAASam pleCount(); | 656 *msaaSampleCount = document().settings()->accelerated2dCanvasMSAASam pleCount(); |
655 OwnPtr<ImageBufferSurface> surface = adoptPtr(new Canvas2DImageBufferSur face(deviceSize, *msaaSampleCount, opacityMode, Canvas2DLayerBridge::EnableAccel eration)); | 657 OwnPtr<ImageBufferSurface> surface = adoptPtr(new Canvas2DImageBufferSur face(deviceSize, *msaaSampleCount, opacityMode, Canvas2DLayerBridge::EnableAccel eration)); |
656 if (surface->isValid()) | 658 if (surface->isValid()) { |
659 CanvasMetrics::countCanvasContextStat(CanvasMetrics::ContextCreatedW ithGPUAccelerated); | |
Justin Novosad
2015/11/19 20:36:08
GPUAccelerated2DCanvasImageBufferCreated
zmin
2015/11/19 22:23:36
Done.
| |
657 return surface.release(); | 660 return surface.release(); |
661 } | |
662 CanvasMetrics::countCanvasContextStat(CanvasMetrics::GPUContextCreationF ailed); | |
Justin Novosad
2015/11/19 20:36:08
GPUAccelerated2DCanvasImageBufferCreationFailed
zmin
2015/11/19 22:23:36
Done.
| |
658 } | 663 } |
659 | 664 |
660 OwnPtr<RecordingImageBufferFallbackSurfaceFactory> surfaceFactory = adoptPtr (new UnacceleratedSurfaceFactory()); | 665 OwnPtr<RecordingImageBufferFallbackSurfaceFactory> surfaceFactory = adoptPtr (new UnacceleratedSurfaceFactory()); |
661 | 666 |
662 if (shouldUseDisplayList(deviceSize)) { | 667 if (shouldUseDisplayList(deviceSize)) { |
663 OwnPtr<ImageBufferSurface> surface = adoptPtr(new RecordingImageBufferSu rface(deviceSize, surfaceFactory.release(), opacityMode)); | 668 OwnPtr<ImageBufferSurface> surface = adoptPtr(new RecordingImageBufferSu rface(deviceSize, surfaceFactory.release(), opacityMode)); |
664 if (surface->isValid()) | 669 if (surface->isValid()) { |
670 CanvasMetrics::countCanvasContextStat(CanvasMetrics::ContextCreatedW ithDisplayList); | |
Justin Novosad
2015/11/19 20:36:08
DisplayList2DCanvasImageBufferCreated
zmin
2015/11/19 22:23:36
Done.
| |
665 return surface.release(); | 671 return surface.release(); |
672 } | |
666 surfaceFactory = adoptPtr(new UnacceleratedSurfaceFactory()); // recreat e because previous one was released | 673 surfaceFactory = adoptPtr(new UnacceleratedSurfaceFactory()); // recreat e because previous one was released |
667 } | 674 } |
668 | 675 CanvasMetrics::countCanvasContextStat(CanvasMetrics::ContextCreatedWithSoftw are); |
Justin Novosad
2015/11/19 20:36:08
Too early to count this, we don't know if it will
zmin
2015/11/19 22:23:36
Done. Also change this to
if (!surface->isValid())
| |
669 return surfaceFactory->createSurface(deviceSize, opacityMode); | 676 auto surface = surfaceFactory->createSurface(deviceSize, opacityMode); |
677 if (!surface->isValid()) { | |
678 CanvasMetrics::countCanvasContextStat(CanvasMetrics::SoftwareContextCrea tionFailed); | |
Justin Novosad
2015/11/19 20:36:08
Unaccelerated2DCanvasImageBufferCreationFailed
zmin
2015/11/19 22:23:36
Done.
| |
679 } | |
680 return surface; | |
670 } | 681 } |
671 | 682 |
672 void HTMLCanvasElement::createImageBuffer() | 683 void HTMLCanvasElement::createImageBuffer() |
673 { | 684 { |
674 createImageBufferInternal(nullptr); | 685 createImageBufferInternal(nullptr); |
675 if (m_didFailToCreateImageBuffer && m_context->is2d() && !size().isEmpty()) | 686 if (m_didFailToCreateImageBuffer && m_context->is2d() && !size().isEmpty()) |
676 m_context->loseContext(CanvasRenderingContext::SyntheticLostContext); | 687 m_context->loseContext(CanvasRenderingContext::SyntheticLostContext); |
677 } | 688 } |
678 | 689 |
679 void HTMLCanvasElement::createImageBufferInternal(PassOwnPtr<ImageBufferSurface> externalSurface) | 690 void HTMLCanvasElement::createImageBufferInternal(PassOwnPtr<ImageBufferSurface> externalSurface) |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
920 { | 931 { |
921 return FloatSize(width(), height()); | 932 return FloatSize(width(), height()); |
922 } | 933 } |
923 | 934 |
924 bool HTMLCanvasElement::isOpaque() const | 935 bool HTMLCanvasElement::isOpaque() const |
925 { | 936 { |
926 return m_context && !m_context->hasAlpha(); | 937 return m_context && !m_context->hasAlpha(); |
927 } | 938 } |
928 | 939 |
929 } // blink | 940 } // blink |
OLD | NEW |