Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(341)

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp

Issue 2294383002: Make OffscreenCanvas a member of CanvasImageSource (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 (renderingContext()->getImage())
261 return true;
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 832 matching lines...) Expand 10 before | Expand all | Expand 10 after
1105 if (!m_context) { 1101 if (!m_context) {
1106 *status = NormalSourceImageStatus; 1102 *status = NormalSourceImageStatus;
1107 return createTransparentImage(size()); 1103 return createTransparentImage(size());
1108 } 1104 }
1109 1105
1110 if (m_context->is3d()) { 1106 if (m_context->is3d()) {
1111 m_context->paintRenderingResultsToCanvas(BackBuffer); 1107 m_context->paintRenderingResultsToCanvas(BackBuffer);
1112 } 1108 }
1113 1109
1114 RefPtr<SkImage> skImage; 1110 RefPtr<SkImage> skImage;
1115 RefPtr<blink::Image> image = renderingContext()->getImage(); 1111 RefPtr<blink::Image> image = renderingContext()->getImage(reason);
1116 1112
1117 if (image) 1113 if (image)
1118 skImage = image->imageForCurrentFrame(); 1114 skImage = image->imageForCurrentFrame();
1119 else
1120 skImage = hasImageBuffer() ? buffer()->newSkImageSnapshot(hint, reason) : createTransparentImage(size())->imageForCurrentFrame();
Justin Novosad 2016/08/31 18:54:23 This code was deleted because getImage() is now im
1121 1115
1122 if (skImage) { 1116 if (skImage) {
1123 *status = NormalSourceImageStatus; 1117 *status = NormalSourceImageStatus;
1124 return StaticBitmapImage::create(skImage.release()); 1118 return StaticBitmapImage::create(skImage.release());
1125 } 1119 }
1126 1120
1127 *status = InvalidSourceImageStatus; 1121 *status = InvalidSourceImageStatus;
1128 return nullptr; 1122 return nullptr;
1129 } 1123 }
1130 1124
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1233 1227
1234 bool HTMLCanvasElement::createSurfaceLayer() 1228 bool HTMLCanvasElement::createSurfaceLayer()
1235 { 1229 {
1236 DCHECK(!m_surfaceLayerBridge); 1230 DCHECK(!m_surfaceLayerBridge);
1237 std::unique_ptr<CanvasSurfaceLayerBridgeClient> bridgeClient = wrapUnique(ne w CanvasSurfaceLayerBridgeClientImpl()); 1231 std::unique_ptr<CanvasSurfaceLayerBridgeClient> bridgeClient = wrapUnique(ne w CanvasSurfaceLayerBridgeClientImpl());
1238 m_surfaceLayerBridge = wrapUnique(new CanvasSurfaceLayerBridge(std::move(bri dgeClient))); 1232 m_surfaceLayerBridge = wrapUnique(new CanvasSurfaceLayerBridge(std::move(bri dgeClient)));
1239 return m_surfaceLayerBridge->createSurfaceLayer(this->width(), this->height( )); 1233 return m_surfaceLayerBridge->createSurfaceLayer(this->width(), this->height( ));
1240 } 1234 }
1241 1235
1242 } // namespace blink 1236 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698