2015-12-18 09:52:17 +03:00
|
|
|
/* 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 ImageBitmapRenderingContext_h
|
|
|
|
#define ImageBitmapRenderingContext_h
|
|
|
|
|
|
|
|
#include "nsICanvasRenderingContextInternal.h"
|
|
|
|
#include "nsWrapperCache.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
namespace gfx {
|
|
|
|
class DataSourceSurface;
|
2016-04-21 12:30:38 +03:00
|
|
|
class DrawTarget;
|
2015-12-18 09:52:17 +03:00
|
|
|
class SourceSurface;
|
|
|
|
} // namespace gfx
|
|
|
|
|
|
|
|
namespace layers {
|
|
|
|
class Image;
|
|
|
|
class ImageContainer;
|
|
|
|
} // namespace layers
|
|
|
|
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The purpose of ImageBitmapRenderingContext is to provide a faster and
|
2016-10-07 12:14:34 +03:00
|
|
|
* efficient way to display ImageBitmap. Simply call TransferFromImageBitmap()
|
2015-12-18 09:52:17 +03:00
|
|
|
* then we'll transfer the surface of ImageBitmap to this context and then to
|
|
|
|
* use it to display.
|
|
|
|
*
|
|
|
|
* See more details in spec: https://wiki.whatwg.org/wiki/OffscreenCanvas
|
|
|
|
*/
|
|
|
|
class ImageBitmapRenderingContext final
|
|
|
|
: public nsICanvasRenderingContextInternal,
|
|
|
|
public nsWrapperCache {
|
|
|
|
virtual ~ImageBitmapRenderingContext();
|
|
|
|
|
|
|
|
public:
|
|
|
|
ImageBitmapRenderingContext();
|
|
|
|
|
|
|
|
virtual JSObject* WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) override;
|
|
|
|
|
|
|
|
// nsISupports interface + CC
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(ImageBitmapRenderingContext)
|
|
|
|
|
|
|
|
void TransferImageBitmap(ImageBitmap& aImageBitmap);
|
2016-10-07 12:14:34 +03:00
|
|
|
void TransferFromImageBitmap(ImageBitmap& aImageBitmap);
|
2015-12-18 09:52:17 +03:00
|
|
|
|
|
|
|
// nsICanvasRenderingContextInternal
|
2017-12-22 04:14:54 +03:00
|
|
|
virtual int32_t GetWidth() override { return mWidth; }
|
|
|
|
virtual int32_t GetHeight() override { return mHeight; }
|
2015-12-18 09:52:17 +03:00
|
|
|
|
|
|
|
NS_IMETHOD SetDimensions(int32_t aWidth, int32_t aHeight) override;
|
|
|
|
|
2016-04-21 12:30:38 +03:00
|
|
|
NS_IMETHOD InitializeWithDrawTarget(
|
2016-08-23 11:41:21 +03:00
|
|
|
nsIDocShell* aDocShell, NotNull<gfx::DrawTarget*> aTarget) override;
|
2015-12-18 09:52:17 +03:00
|
|
|
|
|
|
|
virtual mozilla::UniquePtr<uint8_t[]> GetImageBuffer(
|
|
|
|
int32_t* aFormat) override;
|
|
|
|
NS_IMETHOD GetInputStream(const char* aMimeType,
|
2019-04-08 04:51:17 +03:00
|
|
|
const nsAString& aEncoderOptions,
|
2015-12-18 09:52:17 +03:00
|
|
|
nsIInputStream** aStream) override;
|
|
|
|
|
|
|
|
virtual already_AddRefed<mozilla::gfx::SourceSurface> GetSurfaceSnapshot(
|
2017-04-12 12:55:23 +03:00
|
|
|
gfxAlphaType* aOutAlphaType) override;
|
2015-12-18 09:52:17 +03:00
|
|
|
|
2018-05-02 18:23:53 +03:00
|
|
|
virtual void SetOpaqueValueFromOpaqueAttr(bool aOpaqueAttrValue) override;
|
2015-12-18 09:52:17 +03:00
|
|
|
virtual bool GetIsOpaque() override;
|
|
|
|
NS_IMETHOD Reset() override;
|
|
|
|
virtual already_AddRefed<Layer> GetCanvasLayer(
|
|
|
|
nsDisplayListBuilder* aBuilder, Layer* aOldLayer,
|
2017-09-16 01:06:56 +03:00
|
|
|
LayerManager* aManager) override;
|
2015-12-18 09:52:17 +03:00
|
|
|
virtual void MarkContextClean() override;
|
|
|
|
|
|
|
|
NS_IMETHOD Redraw(const gfxRect& aDirty) override;
|
|
|
|
NS_IMETHOD SetIsIPC(bool aIsIPC) override;
|
|
|
|
|
|
|
|
virtual void DidRefresh() override;
|
|
|
|
|
|
|
|
virtual void MarkContextCleanForFrameCapture() override;
|
|
|
|
virtual bool IsContextCleanForFrameCapture() override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
already_AddRefed<gfx::DataSourceSurface> MatchWithIntrinsicSize();
|
|
|
|
already_AddRefed<layers::Image> ClipToIntrinsicSize();
|
|
|
|
int32_t mWidth;
|
|
|
|
int32_t mHeight;
|
|
|
|
|
|
|
|
RefPtr<layers::Image> mImage;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif /* ImageBitmapRenderingContext_h */
|