| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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/imagebitmap/ImageBitmapOptions.h" | 46 #include "core/imagebitmap/ImageBitmapOptions.h" |
| 47 #include "core/layout/LayoutHTMLCanvas.h" | 47 #include "core/layout/LayoutHTMLCanvas.h" |
| 48 #include "core/paint/PaintLayer.h" | 48 #include "core/paint/PaintLayer.h" |
| 49 #include "platform/MIMETypeRegistry.h" | 49 #include "platform/MIMETypeRegistry.h" |
| 50 #include "platform/RuntimeEnabledFeatures.h" | 50 #include "platform/RuntimeEnabledFeatures.h" |
| 51 #include "platform/graphics/Canvas2DImageBufferSurface.h" | 51 #include "platform/graphics/Canvas2DImageBufferSurface.h" |
| 52 #include "platform/graphics/CanvasMetrics.h" | 52 #include "platform/graphics/CanvasMetrics.h" |
| 53 #include "platform/graphics/ColorSpaceFilter.h" |
| 54 #include "platform/graphics/ColorSpaceProfile.h" |
| 53 #include "platform/graphics/ExpensiveCanvasHeuristicParameters.h" | 55 #include "platform/graphics/ExpensiveCanvasHeuristicParameters.h" |
| 56 #include "platform/graphics/GraphicsScreen.h" |
| 54 #include "platform/graphics/ImageBuffer.h" | 57 #include "platform/graphics/ImageBuffer.h" |
| 55 #include "platform/graphics/RecordingImageBufferSurface.h" | 58 #include "platform/graphics/RecordingImageBufferSurface.h" |
| 56 #include "platform/graphics/StaticBitmapImage.h" | 59 #include "platform/graphics/StaticBitmapImage.h" |
| 57 #include "platform/graphics/UnacceleratedImageBufferSurface.h" | 60 #include "platform/graphics/UnacceleratedImageBufferSurface.h" |
| 58 #include "platform/graphics/gpu/AcceleratedImageBufferSurface.h" | 61 #include "platform/graphics/gpu/AcceleratedImageBufferSurface.h" |
| 59 #include "platform/transforms/AffineTransform.h" | 62 #include "platform/transforms/AffineTransform.h" |
| 60 #include "public/platform/Platform.h" | 63 #include "public/platform/Platform.h" |
| 61 #include "public/platform/WebTraceLocation.h" | 64 #include "public/platform/WebTraceLocation.h" |
| 62 #include <math.h> | 65 #include <math.h> |
| 63 #include <v8.h> | 66 #include <v8.h> |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 if (listener->needsNewFrame()) { | 447 if (listener->needsNewFrame()) { |
| 445 listener->sendNewFrame(image); | 448 listener->sendNewFrame(image); |
| 446 } | 449 } |
| 447 } | 450 } |
| 448 } | 451 } |
| 449 | 452 |
| 450 } | 453 } |
| 451 | 454 |
| 452 void HTMLCanvasElement::paint(GraphicsContext& context, const LayoutRect& r) | 455 void HTMLCanvasElement::paint(GraphicsContext& context, const LayoutRect& r) |
| 453 { | 456 { |
| 457 RELEASE_ASSERT(currentScreenId()); // There should be an active graphics scr
een. |
| 458 |
| 454 // FIXME: crbug.com/438240; there is a bug with the new CSS blending and com
positing feature. | 459 // FIXME: crbug.com/438240; there is a bug with the new CSS blending and com
positing feature. |
| 455 if (!m_context) | 460 if (!m_context) |
| 456 return; | 461 return; |
| 462 |
| 457 if (!paintsIntoCanvasBuffer() && !document().printing()) | 463 if (!paintsIntoCanvasBuffer() && !document().printing()) |
| 458 return; | 464 return; |
| 459 | 465 |
| 460 m_context->paintRenderingResultsToCanvas(FrontBuffer); | 466 m_context->paintRenderingResultsToCanvas(FrontBuffer); |
| 467 |
| 468 RefPtr<SkColorFilter> colorTransform; |
| 469 if (RefPtr<ColorSpaceProfile> source = screenColorProfile(ScreenDevice::sRGB
)) { |
| 470 RefPtr<ColorSpaceProfile> target = screenColorProfile(currentScreenId())
; |
| 471 colorTransform = createColorSpaceFilter(source.get(), target.get()); |
| 472 } |
| 473 |
| 461 if (hasImageBuffer()) { | 474 if (hasImageBuffer()) { |
| 462 if (!context.contextDisabled()) { | 475 if (!context.contextDisabled()) { |
| 463 SkXfermode::Mode compositeOperator = !m_context || m_context->hasAlp
ha() ? SkXfermode::kSrcOver_Mode : SkXfermode::kSrc_Mode; | 476 SkXfermode::Mode compositeOperator = !m_context || m_context->hasAlp
ha() ? SkXfermode::kSrcOver_Mode : SkXfermode::kSrc_Mode; |
| 464 buffer()->draw(context, pixelSnappedIntRect(r), 0, compositeOperator
); | 477 buffer()->draw(context, pixelSnappedIntRect(r), 0, compositeOperator
, colorTransform.get()); |
| 465 } | 478 } |
| 466 } else { | 479 } else { |
| 467 // When alpha is false, we should draw to opaque black. | 480 // When alpha is false, we should draw to opaque black. |
| 468 if (!m_context->hasAlpha()) | 481 if (!m_context->hasAlpha()) |
| 469 context.fillRect(FloatRect(r), Color(0, 0, 0)); | 482 context.fillRect(FloatRect(r), Color(0, 0, 0)); |
| 470 } | 483 } |
| 471 | 484 |
| 472 if (is3D() && paintsIntoCanvasBuffer()) | 485 if (is3D() && paintsIntoCanvasBuffer()) |
| 473 m_context->markLayerComposited(); | 486 m_context->markLayerComposited(); |
| 474 } | 487 } |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 OwnPtr<RecordingImageBufferFallbackSurfaceFactory> surfaceFactory = adoptPtr
(new UnacceleratedSurfaceFactory()); | 743 OwnPtr<RecordingImageBufferFallbackSurfaceFactory> surfaceFactory = adoptPtr
(new UnacceleratedSurfaceFactory()); |
| 731 | 744 |
| 732 if (shouldUseDisplayList(deviceSize)) { | 745 if (shouldUseDisplayList(deviceSize)) { |
| 733 OwnPtr<ImageBufferSurface> surface = adoptPtr(new RecordingImageBufferSu
rface(deviceSize, surfaceFactory.release(), opacityMode)); | 746 OwnPtr<ImageBufferSurface> surface = adoptPtr(new RecordingImageBufferSu
rface(deviceSize, surfaceFactory.release(), opacityMode)); |
| 734 if (surface->isValid()) { | 747 if (surface->isValid()) { |
| 735 CanvasMetrics::countCanvasContextUsage(CanvasMetrics::DisplayList2DC
anvasImageBufferCreated); | 748 CanvasMetrics::countCanvasContextUsage(CanvasMetrics::DisplayList2DC
anvasImageBufferCreated); |
| 736 return surface.release(); | 749 return surface.release(); |
| 737 } | 750 } |
| 738 surfaceFactory = adoptPtr(new UnacceleratedSurfaceFactory()); // recreat
e because previous one was released | 751 surfaceFactory = adoptPtr(new UnacceleratedSurfaceFactory()); // recreat
e because previous one was released |
| 739 } | 752 } |
| 753 |
| 740 auto surface = surfaceFactory->createSurface(deviceSize, opacityMode); | 754 auto surface = surfaceFactory->createSurface(deviceSize, opacityMode); |
| 741 if (!surface->isValid()) { | 755 if (!surface->isValid()) { |
| 742 CanvasMetrics::countCanvasContextUsage(CanvasMetrics::Unaccelerated2DCan
vasImageBufferCreationFailed); | 756 CanvasMetrics::countCanvasContextUsage(CanvasMetrics::Unaccelerated2DCan
vasImageBufferCreationFailed); |
| 743 } else { | 757 } else { |
| 744 CanvasMetrics::countCanvasContextUsage(CanvasMetrics::Unaccelerated2DCan
vasImageBufferCreated); | 758 CanvasMetrics::countCanvasContextUsage(CanvasMetrics::Unaccelerated2DCan
vasImageBufferCreated); |
| 745 } | 759 } |
| 760 |
| 746 return surface; | 761 return surface; |
| 747 } | 762 } |
| 748 | 763 |
| 749 void HTMLCanvasElement::createImageBuffer() | 764 void HTMLCanvasElement::createImageBuffer() |
| 750 { | 765 { |
| 751 createImageBufferInternal(nullptr); | 766 createImageBufferInternal(nullptr); |
| 752 if (m_didFailToCreateImageBuffer && m_context->is2d() && !size().isEmpty()) | 767 if (m_didFailToCreateImageBuffer && m_context->is2d() && !size().isEmpty()) |
| 753 m_context->loseContext(CanvasRenderingContext::SyntheticLostContext); | 768 m_context->loseContext(CanvasRenderingContext::SyntheticLostContext); |
| 754 } | 769 } |
| 755 | 770 |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1013 } | 1028 } |
| 1014 return ImageBitmapSource::fulfillImageBitmap(scriptState, isPaintable() ? Im
ageBitmap::create(this, IntRect(sx, sy, sw, sh), options) : nullptr); | 1029 return ImageBitmapSource::fulfillImageBitmap(scriptState, isPaintable() ? Im
ageBitmap::create(this, IntRect(sx, sy, sw, sh), options) : nullptr); |
| 1015 } | 1030 } |
| 1016 | 1031 |
| 1017 bool HTMLCanvasElement::isOpaque() const | 1032 bool HTMLCanvasElement::isOpaque() const |
| 1018 { | 1033 { |
| 1019 return m_context && !m_context->hasAlpha(); | 1034 return m_context && !m_context->hasAlpha(); |
| 1020 } | 1035 } |
| 1021 | 1036 |
| 1022 } // blink | 1037 } // blink |
| OLD | NEW |