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 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1119 if (!isPaintable()) { | 1119 if (!isPaintable()) { |
1120 *status = InvalidSourceImageStatus; | 1120 *status = InvalidSourceImageStatus; |
1121 return nullptr; | 1121 return nullptr; |
1122 } | 1122 } |
1123 | 1123 |
1124 if (!m_context) { | 1124 if (!m_context) { |
1125 *status = NormalSourceImageStatus; | 1125 *status = NormalSourceImageStatus; |
1126 return createTransparentImage(size()); | 1126 return createTransparentImage(size()); |
1127 } | 1127 } |
1128 | 1128 |
| 1129 sk_sp<SkImage> skImage; |
1129 if (m_context->is3d()) { | 1130 if (m_context->is3d()) { |
1130 m_context->paintRenderingResultsToCanvas(BackBuffer); | 1131 // Because WebGL sources always require making a copy of the back buffer
, we |
| 1132 // use paintRenderingResultsToCanvas instead of getImage in order to kee
p a cached |
| 1133 // copy of the backing in the canvas's ImageBuffer. |
| 1134 renderingContext()->paintRenderingResultsToCanvas(BackBuffer); |
| 1135 skImage = hasImageBuffer() ? buffer()->newSkImageSnapshot(hint, reason)
: createTransparentImage(size())->imageForCurrentFrame(); |
| 1136 } else { |
| 1137 RefPtr<blink::Image> image = renderingContext()->getImage(hint, reason); |
| 1138 skImage = image ? image->imageForCurrentFrame() : createTransparentImage
(size())->imageForCurrentFrame(); |
1131 } | 1139 } |
1132 | 1140 |
1133 sk_sp<SkImage> skImage; | |
1134 RefPtr<blink::Image> image = renderingContext()->getImage(reason); | |
1135 | |
1136 if (image) | |
1137 skImage = image->imageForCurrentFrame(); | |
1138 | |
1139 if (skImage) { | 1141 if (skImage) { |
1140 *status = NormalSourceImageStatus; | 1142 *status = NormalSourceImageStatus; |
1141 return StaticBitmapImage::create(std::move(skImage)); | 1143 return StaticBitmapImage::create(std::move(skImage)); |
1142 } | 1144 } |
1143 | 1145 |
1144 *status = InvalidSourceImageStatus; | 1146 *status = InvalidSourceImageStatus; |
1145 return nullptr; | 1147 return nullptr; |
1146 } | 1148 } |
1147 | 1149 |
1148 bool HTMLCanvasElement::wouldTaintOrigin(SecurityOrigin*) const | 1150 bool HTMLCanvasElement::wouldTaintOrigin(SecurityOrigin*) const |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1250 | 1252 |
1251 bool HTMLCanvasElement::createSurfaceLayer() | 1253 bool HTMLCanvasElement::createSurfaceLayer() |
1252 { | 1254 { |
1253 DCHECK(!m_surfaceLayerBridge); | 1255 DCHECK(!m_surfaceLayerBridge); |
1254 std::unique_ptr<CanvasSurfaceLayerBridgeClient> bridgeClient = wrapUnique(ne
w CanvasSurfaceLayerBridgeClientImpl()); | 1256 std::unique_ptr<CanvasSurfaceLayerBridgeClient> bridgeClient = wrapUnique(ne
w CanvasSurfaceLayerBridgeClientImpl()); |
1255 m_surfaceLayerBridge = wrapUnique(new CanvasSurfaceLayerBridge(std::move(bri
dgeClient))); | 1257 m_surfaceLayerBridge = wrapUnique(new CanvasSurfaceLayerBridge(std::move(bri
dgeClient))); |
1256 return m_surfaceLayerBridge->createSurfaceLayer(this->width(), this->height(
)); | 1258 return m_surfaceLayerBridge->createSurfaceLayer(this->width(), this->height(
)); |
1257 } | 1259 } |
1258 | 1260 |
1259 } // namespace blink | 1261 } // namespace blink |
OLD | NEW |