| 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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 | 250 |
| 251 bool HTMLCanvasElement::shouldBeDirectComposited() const | 251 bool HTMLCanvasElement::shouldBeDirectComposited() const |
| 252 { | 252 { |
| 253 return (m_context && m_context->isAccelerated()) || (hasImageBuffer() && buf
fer()->isExpensiveToPaint()) || (!!m_surfaceLayerBridge); | 253 return (m_context && m_context->isAccelerated()) || (hasImageBuffer() && buf
fer()->isExpensiveToPaint()) || (!!m_surfaceLayerBridge); |
| 254 } | 254 } |
| 255 | 255 |
| 256 bool HTMLCanvasElement::isPaintable() const | 256 bool HTMLCanvasElement::isPaintable() const |
| 257 { | 257 { |
| 258 if (!m_context) | 258 if (!m_context) |
| 259 return ImageBuffer::canCreateImageBuffer(size()); | 259 return ImageBuffer::canCreateImageBuffer(size()); |
| 260 if (renderingContext()->getImage()) |
| 261 return true; |
| 260 return buffer(); | 262 return buffer(); |
| 261 } | 263 } |
| 262 | 264 |
| 263 void HTMLCanvasElement::didDraw(const FloatRect& rect) | 265 void HTMLCanvasElement::didDraw(const FloatRect& rect) |
| 264 { | 266 { |
| 265 if (rect.isEmpty()) | 267 if (rect.isEmpty()) |
| 266 return; | 268 return; |
| 267 m_imageBufferIsClear = false; | 269 m_imageBufferIsClear = false; |
| 268 clearCopiedImage(); | 270 clearCopiedImage(); |
| 269 if (layoutObject()) | 271 if (layoutObject()) |
| (...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1095 | 1097 |
| 1096 if (!m_context) { | 1098 if (!m_context) { |
| 1097 *status = NormalSourceImageStatus; | 1099 *status = NormalSourceImageStatus; |
| 1098 return createTransparentImage(size()); | 1100 return createTransparentImage(size()); |
| 1099 } | 1101 } |
| 1100 | 1102 |
| 1101 if (m_context->is3d()) { | 1103 if (m_context->is3d()) { |
| 1102 m_context->paintRenderingResultsToCanvas(BackBuffer); | 1104 m_context->paintRenderingResultsToCanvas(BackBuffer); |
| 1103 } | 1105 } |
| 1104 | 1106 |
| 1105 RefPtr<SkImage> image = buffer()->newSkImageSnapshot(hint, reason); | 1107 RefPtr<SkImage> skImage; |
| 1106 if (image) { | 1108 RefPtr<blink::Image> image = renderingContext()->getImage(); |
| 1109 |
| 1110 if (image) |
| 1111 skImage = image->imageForCurrentFrame(); |
| 1112 else |
| 1113 skImage = hasImageBuffer() ? buffer()->newSkImageSnapshot(hint, reason)
: createTransparentImage(size())->imageForCurrentFrame(); |
| 1114 |
| 1115 if (skImage) { |
| 1107 *status = NormalSourceImageStatus; | 1116 *status = NormalSourceImageStatus; |
| 1108 return StaticBitmapImage::create(image.release()); | 1117 return StaticBitmapImage::create(skImage.release()); |
| 1109 } | 1118 } |
| 1110 | 1119 |
| 1111 *status = InvalidSourceImageStatus; | 1120 *status = InvalidSourceImageStatus; |
| 1112 return nullptr; | 1121 return nullptr; |
| 1113 } | 1122 } |
| 1114 | 1123 |
| 1115 bool HTMLCanvasElement::wouldTaintOrigin(SecurityOrigin*) const | 1124 bool HTMLCanvasElement::wouldTaintOrigin(SecurityOrigin*) const |
| 1116 { | 1125 { |
| 1117 return !originClean(); | 1126 return !originClean(); |
| 1118 } | 1127 } |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1217 | 1226 |
| 1218 bool HTMLCanvasElement::createSurfaceLayer() | 1227 bool HTMLCanvasElement::createSurfaceLayer() |
| 1219 { | 1228 { |
| 1220 DCHECK(!m_surfaceLayerBridge); | 1229 DCHECK(!m_surfaceLayerBridge); |
| 1221 std::unique_ptr<CanvasSurfaceLayerBridgeClient> bridgeClient = wrapUnique(ne
w CanvasSurfaceLayerBridgeClientImpl()); | 1230 std::unique_ptr<CanvasSurfaceLayerBridgeClient> bridgeClient = wrapUnique(ne
w CanvasSurfaceLayerBridgeClientImpl()); |
| 1222 m_surfaceLayerBridge = wrapUnique(new CanvasSurfaceLayerBridge(std::move(bri
dgeClient))); | 1231 m_surfaceLayerBridge = wrapUnique(new CanvasSurfaceLayerBridge(std::move(bri
dgeClient))); |
| 1223 return m_surfaceLayerBridge->createSurfaceLayer(this->width(), this->height(
)); | 1232 return m_surfaceLayerBridge->createSurfaceLayer(this->width(), this->height(
)); |
| 1224 } | 1233 } |
| 1225 | 1234 |
| 1226 } // namespace blink | 1235 } // namespace blink |
| OLD | NEW |