| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 #include "platform/graphics/RecordingImageBufferSurface.h" | 65 #include "platform/graphics/RecordingImageBufferSurface.h" |
| 66 #include "platform/graphics/StaticBitmapImage.h" | 66 #include "platform/graphics/StaticBitmapImage.h" |
| 67 #include "platform/graphics/UnacceleratedImageBufferSurface.h" | 67 #include "platform/graphics/UnacceleratedImageBufferSurface.h" |
| 68 #include "platform/graphics/gpu/AcceleratedImageBufferSurface.h" | 68 #include "platform/graphics/gpu/AcceleratedImageBufferSurface.h" |
| 69 #include "platform/image-encoders/ImageEncoderUtils.h" | 69 #include "platform/image-encoders/ImageEncoderUtils.h" |
| 70 #include "platform/transforms/AffineTransform.h" | 70 #include "platform/transforms/AffineTransform.h" |
| 71 #include "public/platform/InterfaceProvider.h" | 71 #include "public/platform/InterfaceProvider.h" |
| 72 #include "public/platform/Platform.h" | 72 #include "public/platform/Platform.h" |
| 73 #include "public/platform/WebTraceLocation.h" | 73 #include "public/platform/WebTraceLocation.h" |
| 74 #include "public/platform/modules/offscreencanvas/offscreen_canvas_surface.mojom
-blink.h" | 74 #include "public/platform/modules/offscreencanvas/offscreen_canvas_surface.mojom
-blink.h" |
| 75 #include "skia/ext/cdl_canvas.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 |
| 81 namespace blink { | 82 namespace blink { |
| 82 | 83 |
| 83 using namespace HTMLNames; | 84 using namespace HTMLNames; |
| 84 | 85 |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 | 367 |
| 367 m_context->incrementFrameCount(); | 368 m_context->incrementFrameCount(); |
| 368 } | 369 } |
| 369 | 370 |
| 370 void HTMLCanvasElement::didDisableAcceleration() { | 371 void HTMLCanvasElement::didDisableAcceleration() { |
| 371 // We must force a paint invalidation on the canvas even if it's | 372 // We must force a paint invalidation on the canvas even if it's |
| 372 // content did not change because it layer was destroyed. | 373 // content did not change because it layer was destroyed. |
| 373 didDraw(FloatRect(0, 0, size().width(), size().height())); | 374 didDraw(FloatRect(0, 0, size().width(), size().height())); |
| 374 } | 375 } |
| 375 | 376 |
| 376 void HTMLCanvasElement::restoreCanvasMatrixClipStack(SkCanvas* canvas) const { | 377 void HTMLCanvasElement::restoreCanvasMatrixClipStack(CdlCanvas* canvas) const { |
| 377 if (m_context) | 378 if (m_context) |
| 378 m_context->restoreCanvasMatrixClipStack(canvas); | 379 m_context->restoreCanvasMatrixClipStack(canvas); |
| 379 } | 380 } |
| 380 | 381 |
| 381 void HTMLCanvasElement::doDeferredPaintInvalidation() { | 382 void HTMLCanvasElement::doDeferredPaintInvalidation() { |
| 382 DCHECK(!m_dirtyRect.isEmpty()); | 383 DCHECK(!m_dirtyRect.isEmpty()); |
| 383 if (!m_context->is2d()) { | 384 if (!m_context->is2d()) { |
| 384 didFinalizeFrame(); | 385 didFinalizeFrame(); |
| 385 } else { | 386 } else { |
| 386 DCHECK(hasImageBuffer()); | 387 DCHECK(hasImageBuffer()); |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 | 780 |
| 780 CheckedNumeric<int> checkedCanvasPixelCount = size.width(); | 781 CheckedNumeric<int> checkedCanvasPixelCount = size.width(); |
| 781 checkedCanvasPixelCount *= size.height(); | 782 checkedCanvasPixelCount *= size.height(); |
| 782 if (!checkedCanvasPixelCount.IsValid()) | 783 if (!checkedCanvasPixelCount.IsValid()) |
| 783 return false; | 784 return false; |
| 784 int canvasPixelCount = checkedCanvasPixelCount.ValueOrDie(); | 785 int canvasPixelCount = checkedCanvasPixelCount.ValueOrDie(); |
| 785 | 786 |
| 786 if (RuntimeEnabledFeatures::displayList2dCanvasEnabled()) { | 787 if (RuntimeEnabledFeatures::displayList2dCanvasEnabled()) { |
| 787 #if 0 | 788 #if 0 |
| 788 // TODO(junov): re-enable this code once we solve the problem of recordi
ng | 789 // TODO(junov): re-enable this code once we solve the problem of recordi
ng |
| 789 // GPU-backed images to an SkPicture for cross-context rendering crbug.c
om/490328 | 790 // GPU-backed images to an CdlPicture for cross-context rendering crbug.
com/490328 |
| 790 | 791 |
| 791 // If the compositor provides GPU acceleration to display list canvases,
we | 792 // If the compositor provides GPU acceleration to display list canvases,
we |
| 792 // prefer that over direct acceleration. | 793 // prefer that over direct acceleration. |
| 793 if (document().viewportDescription().matchesHeuristicsForGpuRasterizatio
n()) | 794 if (document().viewportDescription().matchesHeuristicsForGpuRasterizatio
n()) |
| 794 return false; | 795 return false; |
| 795 #endif | 796 #endif |
| 796 // If the GPU resources would be very expensive, prefer a display list. | 797 // If the GPU resources would be very expensive, prefer a display list. |
| 797 if (canvasPixelCount > ExpensiveCanvasHeuristicParameters:: | 798 if (canvasPixelCount > ExpensiveCanvasHeuristicParameters:: |
| 798 PreferDisplayListOverGpuSizeThreshold) | 799 PreferDisplayListOverGpuSizeThreshold) |
| 799 return false; | 800 return false; |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1045 checkedExternallyAllocatedMemory.ValueOrDefault( | 1046 checkedExternallyAllocatedMemory.ValueOrDefault( |
| 1046 std::numeric_limits<intptr_t>::max()); | 1047 std::numeric_limits<intptr_t>::max()); |
| 1047 | 1048 |
| 1048 // Subtracting two intptr_t that are known to be positive will never | 1049 // Subtracting two intptr_t that are known to be positive will never |
| 1049 // underflow. | 1050 // underflow. |
| 1050 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory( | 1051 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory( |
| 1051 externallyAllocatedMemory - m_externallyAllocatedMemory); | 1052 externallyAllocatedMemory - m_externallyAllocatedMemory); |
| 1052 m_externallyAllocatedMemory = externallyAllocatedMemory; | 1053 m_externallyAllocatedMemory = externallyAllocatedMemory; |
| 1053 } | 1054 } |
| 1054 | 1055 |
| 1055 SkCanvas* HTMLCanvasElement::drawingCanvas() const { | 1056 CdlCanvas* HTMLCanvasElement::drawingCanvas() const { |
| 1056 return buffer() ? m_imageBuffer->canvas() : nullptr; | 1057 return buffer() ? m_imageBuffer->canvas() : nullptr; |
| 1057 } | 1058 } |
| 1058 | 1059 |
| 1059 void HTMLCanvasElement::disableDeferral(DisableDeferralReason reason) const { | 1060 void HTMLCanvasElement::disableDeferral(DisableDeferralReason reason) const { |
| 1060 if (buffer()) | 1061 if (buffer()) |
| 1061 m_imageBuffer->disableDeferral(reason); | 1062 m_imageBuffer->disableDeferral(reason); |
| 1062 } | 1063 } |
| 1063 | 1064 |
| 1064 SkCanvas* HTMLCanvasElement::existingDrawingCanvas() const { | 1065 CdlCanvas* HTMLCanvasElement::existingDrawingCanvas() const { |
| 1065 if (!hasImageBuffer()) | 1066 if (!hasImageBuffer()) |
| 1066 return nullptr; | 1067 return nullptr; |
| 1067 | 1068 |
| 1068 return m_imageBuffer->canvas(); | 1069 return m_imageBuffer->canvas(); |
| 1069 } | 1070 } |
| 1070 | 1071 |
| 1071 ImageBuffer* HTMLCanvasElement::buffer() const { | 1072 ImageBuffer* HTMLCanvasElement::buffer() const { |
| 1072 DCHECK(m_context); | 1073 DCHECK(m_context); |
| 1073 DCHECK(m_context->getContextType() != | 1074 DCHECK(m_context->getContextType() != |
| 1074 CanvasRenderingContext::ContextImageBitmap); | 1075 CanvasRenderingContext::ContextImageBitmap); |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1369 mojom::blink::OffscreenCanvasSurfacePtr service; | 1370 mojom::blink::OffscreenCanvasSurfacePtr service; |
| 1370 Platform::current()->interfaceProvider()->getInterface( | 1371 Platform::current()->interfaceProvider()->getInterface( |
| 1371 mojo::GetProxy(&service)); | 1372 mojo::GetProxy(&service)); |
| 1372 m_surfaceLayerBridge = | 1373 m_surfaceLayerBridge = |
| 1373 wrapUnique(new CanvasSurfaceLayerBridge(std::move(service))); | 1374 wrapUnique(new CanvasSurfaceLayerBridge(std::move(service))); |
| 1374 return m_surfaceLayerBridge->createSurfaceLayer(this->width(), | 1375 return m_surfaceLayerBridge->createSurfaceLayer(this->width(), |
| 1375 this->height()); | 1376 this->height()); |
| 1376 } | 1377 } |
| 1377 | 1378 |
| 1378 } // namespace blink | 1379 } // namespace blink |
| OLD | NEW |