Bug 1172796 - Part 3: Implement OffscreenCanvas constructor. r=roc r=smaug

This commit is contained in:
Morris Tseng 2015-12-18 14:52:17 +08:00
parent f7128495a2
commit fa7da0ed58
3 changed files with 26 additions and 6 deletions

View File

@ -70,6 +70,18 @@ OffscreenCanvas::WrapObject(JSContext* aCx,
return OffscreenCanvasBinding::Wrap(aCx, this, aGivenProto);
}
/* static */ already_AddRefed<OffscreenCanvas>
OffscreenCanvas::Constructor(const GlobalObject& aGlobal,
uint32_t aWidth,
uint32_t aHeight,
ErrorResult& aRv)
{
RefPtr<OffscreenCanvas> offscreenCanvas =
new OffscreenCanvas(aWidth, aHeight,
layers::LayersBackend::LAYERS_NONE, nullptr);
return offscreenCanvas.forget();
}
void
OffscreenCanvas::ClearResources()
{
@ -167,6 +179,12 @@ OffscreenCanvas::CreateContext(CanvasContextType aContextType)
void
OffscreenCanvas::CommitFrameToCompositor()
{
if (!mCanvasRenderer) {
// This offscreen canvas doesn't associate to any HTML canvas element.
// So, just bail out.
return;
}
// The attributes has changed, we have to notify main
// thread to change canvas size.
if (mAttrDirty) {

View File

@ -63,6 +63,12 @@ public:
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
static already_AddRefed<OffscreenCanvas>
Constructor(const GlobalObject& aGlobal,
uint32_t aWidth,
uint32_t aHeight,
ErrorResult& aRv);
void ClearResources();
uint32_t Width() const

View File

@ -5,14 +5,10 @@
*
* For more information on this interface, please see
* https://wiki.whatwg.org/wiki/OffscreenCanvas
*
* Current implementation focus on transfer canvas from main thread to worker.
* So there are some spec doesn't implement, such as [Constructor], toBlob() and
* transferToImageBitmap in OffscreenCanvas. Bug 1172796 will implement
* remaining spec.
*/
[Exposed=(Window,Worker),
[Constructor(unsigned long width, unsigned long height),
Exposed=(Window,Worker),
Func="mozilla::dom::OffscreenCanvas::PrefEnabled"]
interface OffscreenCanvas : EventTarget {
[Pure, SetterThrows]