| 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 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1117 } | 1117 } | 
| 1118 | 1118 | 
| 1119 PassRefPtr<Image> HTMLCanvasElement::copiedImage( | 1119 PassRefPtr<Image> HTMLCanvasElement::copiedImage( | 
| 1120     SourceDrawingBuffer sourceBuffer, | 1120     SourceDrawingBuffer sourceBuffer, | 
| 1121     AccelerationHint hint) const { | 1121     AccelerationHint hint) const { | 
| 1122   if (!isPaintable()) | 1122   if (!isPaintable()) | 
| 1123     return nullptr; | 1123     return nullptr; | 
| 1124   if (!m_context) | 1124   if (!m_context) | 
| 1125     return createTransparentImage(size()); | 1125     return createTransparentImage(size()); | 
| 1126 | 1126 | 
|  | 1127   if (m_context->getContextType() == | 
|  | 1128       CanvasRenderingContext::ContextImageBitmap) { | 
|  | 1129     RefPtr<Image> image = | 
|  | 1130         m_context->getImage(hint, SnapshotReasonGetCopiedImage); | 
|  | 1131     if (image) | 
|  | 1132       return m_context->getImage(hint, SnapshotReasonGetCopiedImage); | 
|  | 1133     // Special case: transferFromImageBitmap is not yet called. | 
|  | 1134     sk_sp<SkSurface> surface = | 
|  | 1135         SkSurface::MakeRasterN32Premul(width(), height()); | 
|  | 1136     return StaticBitmapImage::create(surface->makeImageSnapshot()); | 
|  | 1137   } | 
|  | 1138 | 
| 1127   bool needToUpdate = !m_copiedImage; | 1139   bool needToUpdate = !m_copiedImage; | 
| 1128   // The concept of SourceDrawingBuffer is valid on only WebGL. | 1140   // The concept of SourceDrawingBuffer is valid on only WebGL. | 
| 1129   if (m_context->is3d()) | 1141   if (m_context->is3d()) | 
| 1130     needToUpdate |= m_context->paintRenderingResultsToCanvas(sourceBuffer); | 1142     needToUpdate |= m_context->paintRenderingResultsToCanvas(sourceBuffer); | 
| 1131   if (needToUpdate && buffer()) { | 1143   if (needToUpdate && buffer()) { | 
| 1132     m_copiedImage = | 1144     m_copiedImage = | 
| 1133         buffer()->newImageSnapshot(hint, SnapshotReasonGetCopiedImage); | 1145         buffer()->newImageSnapshot(hint, SnapshotReasonGetCopiedImage); | 
| 1134     updateExternallyAllocatedMemory(); | 1146     updateExternallyAllocatedMemory(); | 
| 1135   } | 1147   } | 
| 1136   return m_copiedImage; | 1148   return m_copiedImage; | 
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1198   if (!isPaintable()) { | 1210   if (!isPaintable()) { | 
| 1199     *status = InvalidSourceImageStatus; | 1211     *status = InvalidSourceImageStatus; | 
| 1200     return nullptr; | 1212     return nullptr; | 
| 1201   } | 1213   } | 
| 1202 | 1214 | 
| 1203   if (!m_context) { | 1215   if (!m_context) { | 
| 1204     *status = NormalSourceImageStatus; | 1216     *status = NormalSourceImageStatus; | 
| 1205     return createTransparentImage(size()); | 1217     return createTransparentImage(size()); | 
| 1206   } | 1218   } | 
| 1207 | 1219 | 
|  | 1220   if (m_context->getContextType() == CanvasRenderingContext::ContextImageBitmap) | 
|  | 1221     return m_context->getImage(hint, reason); | 
|  | 1222 | 
| 1208   sk_sp<SkImage> skImage; | 1223   sk_sp<SkImage> skImage; | 
| 1209   if (m_context->is3d()) { | 1224   if (m_context->is3d()) { | 
| 1210     // Because WebGL sources always require making a copy of the back buffer, we | 1225     // Because WebGL sources always require making a copy of the back buffer, we | 
| 1211     // use paintRenderingResultsToCanvas instead of getImage in order to keep a | 1226     // use paintRenderingResultsToCanvas instead of getImage in order to keep a | 
| 1212     // cached copy of the backing in the canvas's ImageBuffer. | 1227     // cached copy of the backing in the canvas's ImageBuffer. | 
| 1213     renderingContext()->paintRenderingResultsToCanvas(BackBuffer); | 1228     renderingContext()->paintRenderingResultsToCanvas(BackBuffer); | 
| 1214     skImage = hasImageBuffer() | 1229     skImage = hasImageBuffer() | 
| 1215                   ? buffer()->newSkImageSnapshot(hint, reason) | 1230                   ? buffer()->newSkImageSnapshot(hint, reason) | 
| 1216                   : createTransparentImage(size())->imageForCurrentFrame(); | 1231                   : createTransparentImage(size())->imageForCurrentFrame(); | 
| 1217   } else { | 1232   } else { | 
| (...skipping 15 matching lines...) Expand all  Loading... | 
| 1233 | 1248 | 
| 1234   *status = InvalidSourceImageStatus; | 1249   *status = InvalidSourceImageStatus; | 
| 1235   return nullptr; | 1250   return nullptr; | 
| 1236 } | 1251 } | 
| 1237 | 1252 | 
| 1238 bool HTMLCanvasElement::wouldTaintOrigin(SecurityOrigin*) const { | 1253 bool HTMLCanvasElement::wouldTaintOrigin(SecurityOrigin*) const { | 
| 1239   return !originClean(); | 1254   return !originClean(); | 
| 1240 } | 1255 } | 
| 1241 | 1256 | 
| 1242 FloatSize HTMLCanvasElement::elementSize(const FloatSize&) const { | 1257 FloatSize HTMLCanvasElement::elementSize(const FloatSize&) const { | 
|  | 1258   if (m_context && | 
|  | 1259       m_context->getContextType() == | 
|  | 1260           CanvasRenderingContext::ContextImageBitmap) { | 
|  | 1261     RefPtr<Image> image = | 
|  | 1262         m_context->getImage(PreferNoAcceleration, SnapshotReasonDrawImage); | 
|  | 1263     if (image) | 
|  | 1264       return FloatSize(image->width(), image->height()); | 
|  | 1265     return FloatSize(0, 0); | 
|  | 1266   } | 
| 1243   return FloatSize(width(), height()); | 1267   return FloatSize(width(), height()); | 
| 1244 } | 1268 } | 
| 1245 | 1269 | 
| 1246 IntSize HTMLCanvasElement::bitmapSourceSize() const { | 1270 IntSize HTMLCanvasElement::bitmapSourceSize() const { | 
| 1247   return IntSize(width(), height()); | 1271   return IntSize(width(), height()); | 
| 1248 } | 1272 } | 
| 1249 | 1273 | 
| 1250 ScriptPromise HTMLCanvasElement::createImageBitmap( | 1274 ScriptPromise HTMLCanvasElement::createImageBitmap( | 
| 1251     ScriptState* scriptState, | 1275     ScriptState* scriptState, | 
| 1252     EventTarget& eventTarget, | 1276     EventTarget& eventTarget, | 
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1357   mojom::blink::OffscreenCanvasSurfacePtr service; | 1381   mojom::blink::OffscreenCanvasSurfacePtr service; | 
| 1358   Platform::current()->interfaceProvider()->getInterface( | 1382   Platform::current()->interfaceProvider()->getInterface( | 
| 1359       mojo::GetProxy(&service)); | 1383       mojo::GetProxy(&service)); | 
| 1360   m_surfaceLayerBridge = | 1384   m_surfaceLayerBridge = | 
| 1361       wrapUnique(new CanvasSurfaceLayerBridge(std::move(service))); | 1385       wrapUnique(new CanvasSurfaceLayerBridge(std::move(service))); | 
| 1362   return m_surfaceLayerBridge->createSurfaceLayer(this->width(), | 1386   return m_surfaceLayerBridge->createSurfaceLayer(this->width(), | 
| 1363                                                   this->height()); | 1387                                                   this->height()); | 
| 1364 } | 1388 } | 
| 1365 | 1389 | 
| 1366 }  // namespace blink | 1390 }  // namespace blink | 
| OLD | NEW | 
|---|