2015-10-12 06:21:03 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef MOZILLA_DOM_CANVASRENDERINGCONTEXTHELPER_H_
|
|
|
|
#define MOZILLA_DOM_CANVASRENDERINGCONTEXTHELPER_H_
|
|
|
|
|
|
|
|
#include "mozilla/dom/BindingDeclarations.h"
|
2016-11-03 17:57:33 +03:00
|
|
|
#include "mozilla/layers/LayersTypes.h"
|
2015-10-12 06:21:03 +03:00
|
|
|
#include "nsSize.h"
|
|
|
|
|
|
|
|
class nsICanvasRenderingContextInternal;
|
|
|
|
class nsIGlobalObject;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
class ErrorResult;
|
|
|
|
|
|
|
|
namespace dom {
|
|
|
|
|
2016-11-03 09:57:34 +03:00
|
|
|
class BlobCallback;
|
2015-12-18 09:52:17 +03:00
|
|
|
class EncodeCompleteCallback;
|
2015-10-12 06:21:03 +03:00
|
|
|
|
|
|
|
enum class CanvasContextType : uint8_t {
|
|
|
|
NoContext,
|
|
|
|
Canvas2D,
|
|
|
|
WebGL1,
|
2015-12-18 09:52:17 +03:00
|
|
|
WebGL2,
|
|
|
|
ImageBitmap
|
2015-10-12 06:21:03 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Povides common RenderingContext functionality used by both OffscreenCanvas
|
|
|
|
* and HTMLCanvasElement.
|
|
|
|
*/
|
|
|
|
class CanvasRenderingContextHelper
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual already_AddRefed<nsISupports>
|
|
|
|
GetContext(JSContext* aCx,
|
|
|
|
const nsAString& aContextId,
|
|
|
|
JS::Handle<JS::Value> aContextOptions,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
|
|
|
|
virtual bool GetOpaqueAttr() = 0;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual nsresult UpdateContext(JSContext* aCx,
|
2015-10-18 14:14:22 +03:00
|
|
|
JS::Handle<JS::Value> aNewContextOptions,
|
|
|
|
ErrorResult& aRvForDictionaryInit);
|
2015-10-12 06:21:03 +03:00
|
|
|
|
|
|
|
virtual nsresult ParseParams(JSContext* aCx,
|
|
|
|
const nsAString& aType,
|
|
|
|
const JS::Value& aEncoderOptions,
|
|
|
|
nsAString& outParams,
|
|
|
|
bool* const outCustomParseOptions);
|
|
|
|
|
2016-11-03 09:57:34 +03:00
|
|
|
void ToBlob(JSContext* aCx, nsIGlobalObject* global, BlobCallback& aCallback,
|
2015-10-12 06:21:03 +03:00
|
|
|
const nsAString& aType, JS::Handle<JS::Value> aParams,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
|
2015-12-18 09:52:17 +03:00
|
|
|
void ToBlob(JSContext* aCx, nsIGlobalObject* aGlobal, EncodeCompleteCallback* aCallback,
|
|
|
|
const nsAString& aType, JS::Handle<JS::Value> aParams,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
|
2015-10-12 06:21:03 +03:00
|
|
|
virtual already_AddRefed<nsICanvasRenderingContextInternal>
|
|
|
|
CreateContext(CanvasContextType aContextType);
|
|
|
|
|
2016-11-03 17:57:33 +03:00
|
|
|
already_AddRefed<nsICanvasRenderingContextInternal>
|
|
|
|
CreateContextHelper(CanvasContextType aContextType,
|
|
|
|
layers::LayersBackend aCompositorBackend);
|
|
|
|
|
2015-10-12 06:21:03 +03:00
|
|
|
virtual nsIntSize GetWidthHeight() = 0;
|
|
|
|
|
|
|
|
CanvasContextType mCurrentContextType;
|
|
|
|
nsCOMPtr<nsICanvasRenderingContextInternal> mCurrentContext;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // MOZILLA_DOM_CANVASRENDERINGCONTEXTHELPER_H_
|