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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 #include "platform/Histogram.h" | 61 #include "platform/Histogram.h" |
62 #include "platform/RuntimeEnabledFeatures.h" | 62 #include "platform/RuntimeEnabledFeatures.h" |
63 #include "platform/graphics/Canvas2DImageBufferSurface.h" | 63 #include "platform/graphics/Canvas2DImageBufferSurface.h" |
64 #include "platform/graphics/CanvasMetrics.h" | 64 #include "platform/graphics/CanvasMetrics.h" |
65 #include "platform/graphics/ExpensiveCanvasHeuristicParameters.h" | 65 #include "platform/graphics/ExpensiveCanvasHeuristicParameters.h" |
66 #include "platform/graphics/ImageBuffer.h" | 66 #include "platform/graphics/ImageBuffer.h" |
67 #include "platform/graphics/RecordingImageBufferSurface.h" | 67 #include "platform/graphics/RecordingImageBufferSurface.h" |
68 #include "platform/graphics/StaticBitmapImage.h" | 68 #include "platform/graphics/StaticBitmapImage.h" |
69 #include "platform/graphics/UnacceleratedImageBufferSurface.h" | 69 #include "platform/graphics/UnacceleratedImageBufferSurface.h" |
70 #include "platform/graphics/gpu/AcceleratedImageBufferSurface.h" | 70 #include "platform/graphics/gpu/AcceleratedImageBufferSurface.h" |
| 71 #include "platform/graphics/paint/PaintCanvas.h" |
71 #include "platform/image-encoders/ImageEncoderUtils.h" | 72 #include "platform/image-encoders/ImageEncoderUtils.h" |
72 #include "platform/transforms/AffineTransform.h" | 73 #include "platform/transforms/AffineTransform.h" |
73 #include "public/platform/Platform.h" | 74 #include "public/platform/Platform.h" |
74 #include "public/platform/WebTraceLocation.h" | 75 #include "public/platform/WebTraceLocation.h" |
75 #include "wtf/CheckedNumeric.h" | 76 #include "wtf/CheckedNumeric.h" |
76 #include "wtf/PtrUtil.h" | 77 #include "wtf/PtrUtil.h" |
77 #include <math.h> | 78 #include <math.h> |
78 #include <memory> | 79 #include <memory> |
79 #include <v8.h> | 80 #include <v8.h> |
80 | 81 |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 | 385 |
385 m_context->incrementFrameCount(); | 386 m_context->incrementFrameCount(); |
386 } | 387 } |
387 | 388 |
388 void HTMLCanvasElement::didDisableAcceleration() { | 389 void HTMLCanvasElement::didDisableAcceleration() { |
389 // We must force a paint invalidation on the canvas even if it's | 390 // We must force a paint invalidation on the canvas even if it's |
390 // content did not change because it layer was destroyed. | 391 // content did not change because it layer was destroyed. |
391 didDraw(FloatRect(0, 0, size().width(), size().height())); | 392 didDraw(FloatRect(0, 0, size().width(), size().height())); |
392 } | 393 } |
393 | 394 |
394 void HTMLCanvasElement::restoreCanvasMatrixClipStack(SkCanvas* canvas) const { | 395 void HTMLCanvasElement::restoreCanvasMatrixClipStack( |
| 396 PaintCanvas* canvas) const { |
395 if (m_context) | 397 if (m_context) |
396 m_context->restoreCanvasMatrixClipStack(canvas); | 398 m_context->restoreCanvasMatrixClipStack(canvas); |
397 } | 399 } |
398 | 400 |
399 void HTMLCanvasElement::doDeferredPaintInvalidation() { | 401 void HTMLCanvasElement::doDeferredPaintInvalidation() { |
400 DCHECK(!m_dirtyRect.isEmpty()); | 402 DCHECK(!m_dirtyRect.isEmpty()); |
401 if (!m_context->is2d()) { | 403 if (!m_context->is2d()) { |
402 didFinalizeFrame(); | 404 didFinalizeFrame(); |
403 } else { | 405 } else { |
404 FloatRect srcRect(0, 0, size().width(), size().height()); | 406 FloatRect srcRect(0, 0, size().width(), size().height()); |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 | 813 |
812 CheckedNumeric<int> checkedCanvasPixelCount = size().width(); | 814 CheckedNumeric<int> checkedCanvasPixelCount = size().width(); |
813 checkedCanvasPixelCount *= size().height(); | 815 checkedCanvasPixelCount *= size().height(); |
814 if (!checkedCanvasPixelCount.IsValid()) | 816 if (!checkedCanvasPixelCount.IsValid()) |
815 return false; | 817 return false; |
816 int canvasPixelCount = checkedCanvasPixelCount.ValueOrDie(); | 818 int canvasPixelCount = checkedCanvasPixelCount.ValueOrDie(); |
817 | 819 |
818 if (RuntimeEnabledFeatures::displayList2dCanvasEnabled()) { | 820 if (RuntimeEnabledFeatures::displayList2dCanvasEnabled()) { |
819 #if 0 | 821 #if 0 |
820 // TODO(junov): re-enable this code once we solve the problem of recordi
ng | 822 // TODO(junov): re-enable this code once we solve the problem of recordi
ng |
821 // GPU-backed images to an SkPicture for cross-context rendering crbug.c
om/490328 | 823 // GPU-backed images to a PaintRecord for cross-context rendering crbug.
com/490328 |
822 | 824 |
823 // If the compositor provides GPU acceleration to display list canvases,
we | 825 // If the compositor provides GPU acceleration to display list canvases,
we |
824 // prefer that over direct acceleration. | 826 // prefer that over direct acceleration. |
825 if (document().viewportDescription().matchesHeuristicsForGpuRasterizatio
n()) | 827 if (document().viewportDescription().matchesHeuristicsForGpuRasterizatio
n()) |
826 return false; | 828 return false; |
827 #endif | 829 #endif |
828 // If the GPU resources would be very expensive, prefer a display list. | 830 // If the GPU resources would be very expensive, prefer a display list. |
829 if (canvasPixelCount > ExpensiveCanvasHeuristicParameters:: | 831 if (canvasPixelCount > ExpensiveCanvasHeuristicParameters:: |
830 PreferDisplayListOverGpuSizeThreshold) | 832 PreferDisplayListOverGpuSizeThreshold) |
831 return false; | 833 return false; |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1078 checkedExternallyAllocatedMemory.ValueOrDefault( | 1080 checkedExternallyAllocatedMemory.ValueOrDefault( |
1079 std::numeric_limits<intptr_t>::max()); | 1081 std::numeric_limits<intptr_t>::max()); |
1080 | 1082 |
1081 // Subtracting two intptr_t that are known to be positive will never | 1083 // Subtracting two intptr_t that are known to be positive will never |
1082 // underflow. | 1084 // underflow. |
1083 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory( | 1085 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory( |
1084 externallyAllocatedMemory - m_externallyAllocatedMemory); | 1086 externallyAllocatedMemory - m_externallyAllocatedMemory); |
1085 m_externallyAllocatedMemory = externallyAllocatedMemory; | 1087 m_externallyAllocatedMemory = externallyAllocatedMemory; |
1086 } | 1088 } |
1087 | 1089 |
1088 SkCanvas* HTMLCanvasElement::drawingCanvas() const { | 1090 PaintCanvas* HTMLCanvasElement::drawingCanvas() const { |
1089 return buffer() ? m_imageBuffer->canvas() : nullptr; | 1091 return buffer() ? m_imageBuffer->canvas() : nullptr; |
1090 } | 1092 } |
1091 | 1093 |
1092 void HTMLCanvasElement::disableDeferral(DisableDeferralReason reason) const { | 1094 void HTMLCanvasElement::disableDeferral(DisableDeferralReason reason) const { |
1093 if (buffer()) | 1095 if (buffer()) |
1094 m_imageBuffer->disableDeferral(reason); | 1096 m_imageBuffer->disableDeferral(reason); |
1095 } | 1097 } |
1096 | 1098 |
1097 SkCanvas* HTMLCanvasElement::existingDrawingCanvas() const { | 1099 PaintCanvas* HTMLCanvasElement::existingDrawingCanvas() const { |
1098 if (!hasImageBuffer()) | 1100 if (!hasImageBuffer()) |
1099 return nullptr; | 1101 return nullptr; |
1100 | 1102 |
1101 return m_imageBuffer->canvas(); | 1103 return m_imageBuffer->canvas(); |
1102 } | 1104 } |
1103 | 1105 |
1104 ImageBuffer* HTMLCanvasElement::buffer() const { | 1106 ImageBuffer* HTMLCanvasElement::buffer() const { |
1105 DCHECK(m_context); | 1107 DCHECK(m_context); |
1106 DCHECK(m_context->getContextType() != | 1108 DCHECK(m_context->getContextType() != |
1107 CanvasRenderingContext::ContextImageBitmap); | 1109 CanvasRenderingContext::ContextImageBitmap); |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1426 m_surfaceLayerBridge = WTF::wrapUnique(new CanvasSurfaceLayerBridge(this)); | 1428 m_surfaceLayerBridge = WTF::wrapUnique(new CanvasSurfaceLayerBridge(this)); |
1427 // Creates a placeholder layer first before Surface is created. | 1429 // Creates a placeholder layer first before Surface is created. |
1428 m_surfaceLayerBridge->createSolidColorLayer(); | 1430 m_surfaceLayerBridge->createSolidColorLayer(); |
1429 } | 1431 } |
1430 | 1432 |
1431 void HTMLCanvasElement::OnWebLayerReplaced() { | 1433 void HTMLCanvasElement::OnWebLayerReplaced() { |
1432 setNeedsCompositingUpdate(); | 1434 setNeedsCompositingUpdate(); |
1433 } | 1435 } |
1434 | 1436 |
1435 } // namespace blink | 1437 } // namespace blink |
OLD | NEW |