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

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: fix compile error on win_dbg 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 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 shouldFailContextCreationForTesting = true; 643 shouldFailContextCreationForTesting = true;
644 } 644 }
645 645
646 ImageBitmap* WebGLRenderingContextBase::transferToImageBitmapBase() 646 ImageBitmap* WebGLRenderingContextBase::transferToImageBitmapBase()
647 { 647 {
648 if (!drawingBuffer()) 648 if (!drawingBuffer())
649 return nullptr; 649 return nullptr;
650 return ImageBitmap::create(drawingBuffer()->transferToStaticBitmapImage()); 650 return ImageBitmap::create(drawingBuffer()->transferToStaticBitmapImage());
651 } 651 }
652 652
653 void WebGLRenderingContextBase::commit(ExceptionState& exceptionState)
654 {
655 if (!getOffscreenCanvas()) {
656 exceptionState.throwDOMException(InvalidStateError, "Commit() was called on a rendering context that was not created from an OffscreenCanvas.");
657 return;
658 }
659 // no HTMLCanvas associated, thrown InvalidStateError
660 if (getOffscreenCanvas()->getAssociatedCanvasId() == -1) {
661 exceptionState.throwDOMException(InvalidStateError, "Commit() was called on a context whose OffscreenCanvas is not associated with a canvas element.");
662 return;
663 }
664 if (!drawingBuffer())
665 return;
666 // TODO(crbug.com/646864): Make commit() work correctly with { preserveDrawi ngBuffer : true }.
667 getOffscreenCanvas()->getOrCreateFrameDispatcher()->dispatchFrame(std::move( drawingBuffer()->transferToStaticBitmapImage()));
668 }
669
653 PassRefPtr<Image> WebGLRenderingContextBase::getImage(AccelerationHint hint, Sna pshotReason reason) const 670 PassRefPtr<Image> WebGLRenderingContextBase::getImage(AccelerationHint hint, Sna pshotReason reason) const
654 { 671 {
655 if (!drawingBuffer()) 672 if (!drawingBuffer())
656 return nullptr; 673 return nullptr;
657 674
658 drawingBuffer()->commit(); 675 drawingBuffer()->commit();
659 IntSize size = clampedCanvasSize(); 676 IntSize size = clampedCanvasSize();
660 OpacityMode opacityMode = creationAttributes().hasAlpha() ? NonOpaque : Opaq ue; 677 OpacityMode opacityMode = creationAttributes().hasAlpha() ? NonOpaque : Opaq ue;
661 std::unique_ptr<AcceleratedImageBufferSurface> surface = wrapUnique(new Acce leratedImageBufferSurface(size, opacityMode)); 678 std::unique_ptr<AcceleratedImageBufferSurface> surface = wrapUnique(new Acce leratedImageBufferSurface(size, opacityMode));
662 if (!surface->isValid()) 679 if (!surface->isValid())
(...skipping 5792 matching lines...) Expand 10 before | Expand all | Expand 10 after
6455 6472
6456 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas(HTMLCanvasElementOrOffs creenCanvas& result) const 6473 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas(HTMLCanvasElementOrOffs creenCanvas& result) const
6457 { 6474 {
6458 if (canvas()) 6475 if (canvas())
6459 result.setHTMLCanvasElement(canvas()); 6476 result.setHTMLCanvasElement(canvas());
6460 else 6477 else
6461 result.setOffscreenCanvas(getOffscreenCanvas()); 6478 result.setOffscreenCanvas(getOffscreenCanvas());
6462 } 6479 }
6463 6480
6464 } // namespace blink 6481 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698