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

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

Issue 2653933003: Make stream captures work on canvases that are not in the DOM. (Closed)
Patch Set: rebase Created 3 years, 10 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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 FloatRect inflatedRect = rect; 318 FloatRect inflatedRect = rect;
319 inflatedRect.inflate(1); 319 inflatedRect.inflate(1);
320 m_dirtyRect.unite(inflatedRect); 320 m_dirtyRect.unite(inflatedRect);
321 } else { 321 } else {
322 m_dirtyRect.unite(rect); 322 m_dirtyRect.unite(rect);
323 } 323 }
324 if (m_context && m_context->is2d() && hasImageBuffer()) 324 if (m_context && m_context->is2d() && hasImageBuffer())
325 buffer()->didDraw(rect); 325 buffer()->didDraw(rect);
326 } 326 }
327 327
328 void HTMLCanvasElement::didFinalizeFrame() { 328 void HTMLCanvasElement::finalizeFrame() {
329 if (hasImageBuffer())
330 m_imageBuffer->finalizeFrame();
331 m_context->incrementFrameCount();
329 notifyListenersCanvasChanged(); 332 notifyListenersCanvasChanged();
333 }
334
335 void HTMLCanvasElement::didDisableAcceleration() {
336 // We must force a paint invalidation on the canvas even if it's
337 // content did not change because it layer was destroyed.
338 didDraw(FloatRect(0, 0, size().width(), size().height()));
339 }
340
341 void HTMLCanvasElement::restoreCanvasMatrixClipStack(SkCanvas* canvas) const {
342 if (m_context)
343 m_context->restoreCanvasMatrixClipStack(canvas);
344 }
345
346 void HTMLCanvasElement::doDeferredPaintInvalidation() {
347 DCHECK(!m_dirtyRect.isEmpty());
348 if (m_context->is2d()) {
349 FloatRect srcRect(0, 0, size().width(), size().height());
350 m_dirtyRect.intersect(srcRect);
351 LayoutBox* lb = layoutBox();
352 FloatRect invalidationRect;
353 if (lb) {
354 FloatRect mappedDirtyRect =
355 mapRect(m_dirtyRect, srcRect, FloatRect(lb->contentBoxRect()));
356 if (m_context->isAccelerated()) {
357 // Accelerated 2D canvases need the dirty rect to be expressed relative
358 // to the content box, as opposed to the layout box.
359 mappedDirtyRect.move(-lb->contentBoxOffset());
360 }
361 invalidationRect = mappedDirtyRect;
362 } else {
363 invalidationRect = m_dirtyRect;
364 }
365 if (hasImageBuffer()) {
366 m_imageBuffer->doPaintInvalidation(invalidationRect);
367 }
368 }
330 369
331 if (m_dirtyRect.isEmpty()) 370 if (m_dirtyRect.isEmpty())
332 return; 371 return;
333 372
334 // Propagate the m_dirtyRect accumulated so far to the compositor 373 // Propagate the m_dirtyRect accumulated so far to the compositor
335 // before restarting with a blank dirty rect. 374 // before restarting with a blank dirty rect.
336 FloatRect srcRect(0, 0, size().width(), size().height()); 375 FloatRect srcRect(0, 0, size().width(), size().height());
337 376
338 LayoutBox* ro = layoutBox(); 377 LayoutBox* ro = layoutBox();
339 // Canvas content updates do not need to be propagated as 378 // Canvas content updates do not need to be propagated as
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 m_numFramesSinceLastRenderingModeSwitch = 0; 420 m_numFramesSinceLastRenderingModeSwitch = 0;
382 m_pendingRenderingModeSwitch = true; 421 m_pendingRenderingModeSwitch = true;
383 } 422 }
384 } 423 }
385 } 424 }
386 425
387 if (m_pendingRenderingModeSwitch && buffer() && !buffer()->isAccelerated()) { 426 if (m_pendingRenderingModeSwitch && buffer() && !buffer()->isAccelerated()) {
388 m_pendingRenderingModeSwitch = false; 427 m_pendingRenderingModeSwitch = false;
389 } 428 }
390 429
391 m_context->incrementFrameCount();
392 }
393
394 void HTMLCanvasElement::didDisableAcceleration() {
395 // We must force a paint invalidation on the canvas even if it's
396 // content did not change because it layer was destroyed.
397 didDraw(FloatRect(0, 0, size().width(), size().height()));
398 }
399
400 void HTMLCanvasElement::restoreCanvasMatrixClipStack(
401 PaintCanvas* canvas) const {
402 if (m_context)
403 m_context->restoreCanvasMatrixClipStack(canvas);
404 }
405
406 void HTMLCanvasElement::doDeferredPaintInvalidation() {
407 DCHECK(!m_dirtyRect.isEmpty());
408 if (!m_context->is2d()) {
409 didFinalizeFrame();
410 } else {
411 FloatRect srcRect(0, 0, size().width(), size().height());
412 m_dirtyRect.intersect(srcRect);
413 LayoutBox* lb = layoutBox();
414 FloatRect invalidationRect;
415 if (lb) {
416 FloatRect mappedDirtyRect =
417 mapRect(m_dirtyRect, srcRect, FloatRect(lb->contentBoxRect()));
418 if (m_context->isAccelerated()) {
419 // Accelerated 2D canvases need the dirty rect to be expressed relative
420 // to the content box, as opposed to the layout box.
421 mappedDirtyRect.move(-lb->contentBoxOffset());
422 }
423 invalidationRect = mappedDirtyRect;
424 } else {
425 invalidationRect = m_dirtyRect;
426 }
427 if (hasImageBuffer()) {
428 m_imageBuffer->finalizeFrame(invalidationRect);
429 } else {
430 didFinalizeFrame();
431 }
432 }
433 DCHECK(m_dirtyRect.isEmpty()); 430 DCHECK(m_dirtyRect.isEmpty());
434 } 431 }
435 432
436 void HTMLCanvasElement::reset() { 433 void HTMLCanvasElement::reset() {
437 if (m_ignoreReset) 434 if (m_ignoreReset)
438 return; 435 return;
439 436
440 m_dirtyRect = FloatRect(); 437 m_dirtyRect = FloatRect();
441 438
442 bool ok; 439 bool ok;
(...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after
1444 // Creates a placeholder layer first before Surface is created. 1441 // Creates a placeholder layer first before Surface is created.
1445 m_surfaceLayerBridge->createSolidColorLayer(); 1442 m_surfaceLayerBridge->createSolidColorLayer();
1446 } 1443 }
1447 } 1444 }
1448 1445
1449 void HTMLCanvasElement::OnWebLayerReplaced() { 1446 void HTMLCanvasElement::OnWebLayerReplaced() {
1450 setNeedsCompositingUpdate(); 1447 setNeedsCompositingUpdate();
1451 } 1448 }
1452 1449
1453 } // namespace blink 1450 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698