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

Side by Side Diff: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp

Issue 2328463004: Implement WebGL's commit on the main thread (Closed)
Patch Set: address comments 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) 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2009 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 shouldFailContextCreationForTesting = true; 642 shouldFailContextCreationForTesting = true;
643 } 643 }
644 644
645 ImageBitmap* WebGLRenderingContextBase::transferToImageBitmapBase() 645 ImageBitmap* WebGLRenderingContextBase::transferToImageBitmapBase()
646 { 646 {
647 if (!drawingBuffer()) 647 if (!drawingBuffer())
648 return nullptr; 648 return nullptr;
649 return ImageBitmap::create(drawingBuffer()->transferToStaticBitmapImage()); 649 return ImageBitmap::create(drawingBuffer()->transferToStaticBitmapImage());
650 } 650 }
651 651
652 void WebGLRenderingContextBase::commit(ExceptionState& exceptionState)
653 {
654 if (!getOffscreenCanvas()) {
655 exceptionState.throwDOMException(InvalidStateError, "No OffscreenCanvas exists, abort commit().");
Justin Novosad 2016/09/12 13:53:25 Error message would be more readable like this "Co
xidachen 2016/09/14 01:33:12 Done.
656 return;
657 }
658 // no HTMLCanvas associated, thrown InvalidStateError
659 if (getOffscreenCanvas()->getAssociatedCanvasId() == -1) {
660 exceptionState.throwDOMException(InvalidStateError, "Commit() was called on a context whose OffscreenCanvas is not associated with a canvas element.");
661 return;
662 }
663 if (!drawingBuffer())
664 return;
665 getOffscreenCanvas()->getOrCreateFrameDispatcher()->dispatchFrame(drawingBuf fer()->transferToStaticBitmapImage());
Justin Novosad 2016/09/12 13:53:25 Race condition right here. The return value of dra
666 }
667
652 PassRefPtr<Image> WebGLRenderingContextBase::getImage(AccelerationHint hint, Sna pshotReason reason) const 668 PassRefPtr<Image> WebGLRenderingContextBase::getImage(AccelerationHint hint, Sna pshotReason reason) const
653 { 669 {
654 if (!drawingBuffer()) 670 if (!drawingBuffer())
655 return nullptr; 671 return nullptr;
656 672
657 drawingBuffer()->commit(); 673 drawingBuffer()->commit();
658 IntSize size = clampedCanvasSize(); 674 IntSize size = clampedCanvasSize();
659 OpacityMode opacityMode = creationAttributes().hasAlpha() ? NonOpaque : Opaq ue; 675 OpacityMode opacityMode = creationAttributes().hasAlpha() ? NonOpaque : Opaq ue;
660 std::unique_ptr<AcceleratedImageBufferSurface> surface = wrapUnique(new Acce leratedImageBufferSurface(size, opacityMode)); 676 std::unique_ptr<AcceleratedImageBufferSurface> surface = wrapUnique(new Acce leratedImageBufferSurface(size, opacityMode));
661 if (!surface->isValid()) 677 if (!surface->isValid())
(...skipping 5775 matching lines...) Expand 10 before | Expand all | Expand 10 after
6437 6453
6438 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas(HTMLCanvasElementOrOffs creenCanvas& result) const 6454 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas(HTMLCanvasElementOrOffs creenCanvas& result) const
6439 { 6455 {
6440 if (canvas()) 6456 if (canvas())
6441 result.setHTMLCanvasElement(canvas()); 6457 result.setHTMLCanvasElement(canvas());
6442 else 6458 else
6443 result.setOffscreenCanvas(getOffscreenCanvas()); 6459 result.setOffscreenCanvas(getOffscreenCanvas());
6444 } 6460 }
6445 6461
6446 } // namespace blink 6462 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698