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 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 } | 501 } |
502 } | 502 } |
503 | 503 |
504 if (listenerNeedsNewFrameCapture) { | 504 if (listenerNeedsNewFrameCapture) { |
505 SourceImageStatus status; | 505 SourceImageStatus status; |
506 RefPtr<Image> sourceImage = getSourceImageForCanvas( | 506 RefPtr<Image> sourceImage = getSourceImageForCanvas( |
507 &status, PreferNoAcceleration, SnapshotReasonCanvasListenerCapture, | 507 &status, PreferNoAcceleration, SnapshotReasonCanvasListenerCapture, |
508 FloatSize()); | 508 FloatSize()); |
509 if (status != NormalSourceImageStatus) | 509 if (status != NormalSourceImageStatus) |
510 return; | 510 return; |
511 sk_sp<SkImage> image = sourceImage->imageForCurrentFrame(); | 511 // TODO(ccameron): Canvas should produce sRGB images. |
| 512 // https://crbug.com/672299 |
| 513 sk_sp<SkImage> image = sourceImage->imageForCurrentFrame( |
| 514 ColorBehavior::transformToGlobalTarget()); |
512 for (CanvasDrawListener* listener : m_listeners) { | 515 for (CanvasDrawListener* listener : m_listeners) { |
513 if (listener->needsNewFrame()) { | 516 if (listener->needsNewFrame()) { |
514 listener->sendNewFrame(image); | 517 listener->sendNewFrame(image); |
515 } | 518 } |
516 } | 519 } |
517 } | 520 } |
518 } | 521 } |
519 | 522 |
520 void HTMLCanvasElement::paint(GraphicsContext& context, const LayoutRect& r) { | 523 void HTMLCanvasElement::paint(GraphicsContext& context, const LayoutRect& r) { |
521 // FIXME: crbug.com/438240; there is a bug with the new CSS blending and | 524 // FIXME: crbug.com/438240; there is a bug with the new CSS blending and |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 imageData = ImageData::create(m_size); | 634 imageData = ImageData::create(m_size); |
632 | 635 |
633 if ((!m_context || !imageData) && !placeholderFrame()) | 636 if ((!m_context || !imageData) && !placeholderFrame()) |
634 return imageData; | 637 return imageData; |
635 | 638 |
636 DCHECK((m_context && m_context->is2d()) || placeholderFrame()); | 639 DCHECK((m_context && m_context->is2d()) || placeholderFrame()); |
637 sk_sp<SkImage> snapshot; | 640 sk_sp<SkImage> snapshot; |
638 if (hasImageBuffer()) { | 641 if (hasImageBuffer()) { |
639 snapshot = buffer()->newSkImageSnapshot(PreferNoAcceleration, reason); | 642 snapshot = buffer()->newSkImageSnapshot(PreferNoAcceleration, reason); |
640 } else if (placeholderFrame()) { | 643 } else if (placeholderFrame()) { |
641 snapshot = placeholderFrame()->imageForCurrentFrame(); | 644 // TODO(ccameron): Canvas should produce sRGB images. |
| 645 // https://crbug.com/672299 |
| 646 snapshot = placeholderFrame()->imageForCurrentFrame( |
| 647 ColorBehavior::transformToGlobalTarget()); |
642 } | 648 } |
643 | 649 |
644 if (snapshot) { | 650 if (snapshot) { |
645 SkImageInfo imageInfo = SkImageInfo::Make( | 651 SkImageInfo imageInfo = SkImageInfo::Make( |
646 width(), height(), kRGBA_8888_SkColorType, kUnpremul_SkAlphaType); | 652 width(), height(), kRGBA_8888_SkColorType, kUnpremul_SkAlphaType); |
647 snapshot->readPixels(imageInfo, imageData->data()->data(), | 653 snapshot->readPixels(imageInfo, imageData->data()->data(), |
648 imageInfo.minRowBytes(), 0, 0); | 654 imageInfo.minRowBytes(), 0, 0); |
649 } | 655 } |
650 | 656 |
651 return imageData; | 657 return imageData; |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1218 | 1224 |
1219 if (!m_context) { | 1225 if (!m_context) { |
1220 *status = NormalSourceImageStatus; | 1226 *status = NormalSourceImageStatus; |
1221 return createTransparentImage(size()); | 1227 return createTransparentImage(size()); |
1222 } | 1228 } |
1223 | 1229 |
1224 if (m_context->getContextType() == CanvasRenderingContext::ContextImageBitmap) | 1230 if (m_context->getContextType() == CanvasRenderingContext::ContextImageBitmap) |
1225 return m_context->getImage(hint, reason); | 1231 return m_context->getImage(hint, reason); |
1226 | 1232 |
1227 sk_sp<SkImage> skImage; | 1233 sk_sp<SkImage> skImage; |
| 1234 // TODO(ccameron): Canvas should produce sRGB images. |
| 1235 // https://crbug.com/672299 |
1228 if (m_context->is3d()) { | 1236 if (m_context->is3d()) { |
1229 // Because WebGL sources always require making a copy of the back buffer, we | 1237 // Because WebGL sources always require making a copy of the back buffer, we |
1230 // use paintRenderingResultsToCanvas instead of getImage in order to keep a | 1238 // use paintRenderingResultsToCanvas instead of getImage in order to keep a |
1231 // cached copy of the backing in the canvas's ImageBuffer. | 1239 // cached copy of the backing in the canvas's ImageBuffer. |
1232 renderingContext()->paintRenderingResultsToCanvas(BackBuffer); | 1240 renderingContext()->paintRenderingResultsToCanvas(BackBuffer); |
1233 skImage = hasImageBuffer() | 1241 skImage = hasImageBuffer() |
1234 ? buffer()->newSkImageSnapshot(hint, reason) | 1242 ? buffer()->newSkImageSnapshot(hint, reason) |
1235 : createTransparentImage(size())->imageForCurrentFrame(); | 1243 : createTransparentImage(size())->imageForCurrentFrame( |
| 1244 ColorBehavior::transformToGlobalTarget()); |
1236 } else { | 1245 } else { |
1237 if (ExpensiveCanvasHeuristicParameters:: | 1246 if (ExpensiveCanvasHeuristicParameters:: |
1238 DisableAccelerationToAvoidReadbacks && | 1247 DisableAccelerationToAvoidReadbacks && |
1239 !RuntimeEnabledFeatures::canvas2dFixedRenderingModeEnabled() && | 1248 !RuntimeEnabledFeatures::canvas2dFixedRenderingModeEnabled() && |
1240 hint == PreferNoAcceleration && m_context->isAccelerated() && | 1249 hint == PreferNoAcceleration && m_context->isAccelerated() && |
1241 hasImageBuffer()) | 1250 hasImageBuffer()) |
1242 buffer()->disableAcceleration(); | 1251 buffer()->disableAcceleration(); |
1243 RefPtr<blink::Image> image = renderingContext()->getImage(hint, reason); | 1252 RefPtr<blink::Image> image = renderingContext()->getImage(hint, reason); |
1244 skImage = image ? image->imageForCurrentFrame() | 1253 skImage = image |
1245 : createTransparentImage(size())->imageForCurrentFrame(); | 1254 ? image->imageForCurrentFrame( |
| 1255 ColorBehavior::transformToGlobalTarget()) |
| 1256 : createTransparentImage(size())->imageForCurrentFrame( |
| 1257 ColorBehavior::transformToGlobalTarget()); |
1246 } | 1258 } |
1247 | 1259 |
1248 if (skImage) { | 1260 if (skImage) { |
1249 *status = NormalSourceImageStatus; | 1261 *status = NormalSourceImageStatus; |
1250 return StaticBitmapImage::create(std::move(skImage)); | 1262 return StaticBitmapImage::create(std::move(skImage)); |
1251 } | 1263 } |
1252 | 1264 |
1253 *status = InvalidSourceImageStatus; | 1265 *status = InvalidSourceImageStatus; |
1254 return nullptr; | 1266 return nullptr; |
1255 } | 1267 } |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1387 mojom::blink::OffscreenCanvasSurfacePtr service; | 1399 mojom::blink::OffscreenCanvasSurfacePtr service; |
1388 Platform::current()->interfaceProvider()->getInterface( | 1400 Platform::current()->interfaceProvider()->getInterface( |
1389 mojo::GetProxy(&service)); | 1401 mojo::GetProxy(&service)); |
1390 m_surfaceLayerBridge = | 1402 m_surfaceLayerBridge = |
1391 WTF::wrapUnique(new CanvasSurfaceLayerBridge(std::move(service))); | 1403 WTF::wrapUnique(new CanvasSurfaceLayerBridge(std::move(service))); |
1392 return m_surfaceLayerBridge->createSurfaceLayer(this->width(), | 1404 return m_surfaceLayerBridge->createSurfaceLayer(this->width(), |
1393 this->height()); | 1405 this->height()); |
1394 } | 1406 } |
1395 | 1407 |
1396 } // namespace blink | 1408 } // namespace blink |
OLD | NEW |