| 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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 return m_context.get(); | 248 return m_context.get(); |
| 249 } | 249 } |
| 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 return (m_context && m_context->isPaintable()) || ImageBuffer::canCreateImag
eBuffer(size()); |
| 259 return ImageBuffer::canCreateImageBuffer(size()); | |
| 260 if (m_context->getContextType() == CanvasRenderingContext::ContextImageBitma
p) | |
| 261 return (renderingContext()->getImage().get()); | |
| 262 return buffer(); | |
| 263 } | 259 } |
| 264 | 260 |
| 265 void HTMLCanvasElement::didDraw(const FloatRect& rect) | 261 void HTMLCanvasElement::didDraw(const FloatRect& rect) |
| 266 { | 262 { |
| 267 if (rect.isEmpty()) | 263 if (rect.isEmpty()) |
| 268 return; | 264 return; |
| 269 m_imageBufferIsClear = false; | 265 m_imageBufferIsClear = false; |
| 270 clearCopiedImage(); | 266 clearCopiedImage(); |
| 271 if (layoutObject()) | 267 if (layoutObject()) |
| 272 layoutObject()->setMayNeedPaintInvalidation(); | 268 layoutObject()->setMayNeedPaintInvalidation(); |
| (...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1117 if (!m_context) { | 1113 if (!m_context) { |
| 1118 *status = NormalSourceImageStatus; | 1114 *status = NormalSourceImageStatus; |
| 1119 return createTransparentImage(size()); | 1115 return createTransparentImage(size()); |
| 1120 } | 1116 } |
| 1121 | 1117 |
| 1122 if (m_context->is3d()) { | 1118 if (m_context->is3d()) { |
| 1123 m_context->paintRenderingResultsToCanvas(BackBuffer); | 1119 m_context->paintRenderingResultsToCanvas(BackBuffer); |
| 1124 } | 1120 } |
| 1125 | 1121 |
| 1126 RefPtr<SkImage> skImage; | 1122 RefPtr<SkImage> skImage; |
| 1127 RefPtr<blink::Image> image = renderingContext()->getImage(); | 1123 RefPtr<blink::Image> image = renderingContext()->getImage(reason); |
| 1128 | 1124 |
| 1129 if (image) | 1125 if (image) |
| 1130 skImage = image->imageForCurrentFrame(); | 1126 skImage = image->imageForCurrentFrame(); |
| 1131 else | |
| 1132 skImage = hasImageBuffer() ? buffer()->newSkImageSnapshot(hint, reason)
: createTransparentImage(size())->imageForCurrentFrame(); | |
| 1133 | 1127 |
| 1134 if (skImage) { | 1128 if (skImage) { |
| 1135 *status = NormalSourceImageStatus; | 1129 *status = NormalSourceImageStatus; |
| 1136 return StaticBitmapImage::create(skImage.release()); | 1130 return StaticBitmapImage::create(skImage.release()); |
| 1137 } | 1131 } |
| 1138 | 1132 |
| 1139 *status = InvalidSourceImageStatus; | 1133 *status = InvalidSourceImageStatus; |
| 1140 return nullptr; | 1134 return nullptr; |
| 1141 } | 1135 } |
| 1142 | 1136 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1245 | 1239 |
| 1246 bool HTMLCanvasElement::createSurfaceLayer() | 1240 bool HTMLCanvasElement::createSurfaceLayer() |
| 1247 { | 1241 { |
| 1248 DCHECK(!m_surfaceLayerBridge); | 1242 DCHECK(!m_surfaceLayerBridge); |
| 1249 std::unique_ptr<CanvasSurfaceLayerBridgeClient> bridgeClient = wrapUnique(ne
w CanvasSurfaceLayerBridgeClientImpl()); | 1243 std::unique_ptr<CanvasSurfaceLayerBridgeClient> bridgeClient = wrapUnique(ne
w CanvasSurfaceLayerBridgeClientImpl()); |
| 1250 m_surfaceLayerBridge = wrapUnique(new CanvasSurfaceLayerBridge(std::move(bri
dgeClient))); | 1244 m_surfaceLayerBridge = wrapUnique(new CanvasSurfaceLayerBridge(std::move(bri
dgeClient))); |
| 1251 return m_surfaceLayerBridge->createSurfaceLayer(this->width(), this->height(
)); | 1245 return m_surfaceLayerBridge->createSurfaceLayer(this->width(), this->height(
)); |
| 1252 } | 1246 } |
| 1253 | 1247 |
| 1254 } // namespace blink | 1248 } // namespace blink |
| OLD | NEW |