Bug 1728903 - Remove plumbing for CanvasLayer and ImageLayer. r=mattwoodrow
Differential Revision: https://phabricator.services.mozilla.com/D124406
This commit is contained in:
@@ -5364,49 +5364,6 @@ void CanvasRenderingContext2D::OnBeforePaintTransaction() {
|
|||||||
|
|
||||||
void CanvasRenderingContext2D::OnDidPaintTransaction() { MarkContextClean(); }
|
void CanvasRenderingContext2D::OnDidPaintTransaction() { MarkContextClean(); }
|
||||||
|
|
||||||
already_AddRefed<Layer> CanvasRenderingContext2D::GetCanvasLayer(
|
|
||||||
nsDisplayListBuilder* aBuilder, Layer* aOldLayer, LayerManager* aManager) {
|
|
||||||
if (mOpaque) {
|
|
||||||
// If we're opaque then make sure we have a surface so we paint black
|
|
||||||
// instead of transparent.
|
|
||||||
EnsureTarget();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Don't call EnsureTarget() ... if there isn't already a surface, then
|
|
||||||
// we have nothing to paint and there is no need to create a surface just
|
|
||||||
// to paint nothing. Also, EnsureTarget() can cause creation of a persistent
|
|
||||||
// layer manager which must NOT happen during a paint.
|
|
||||||
if (!mBufferProvider && !IsTargetValid()) {
|
|
||||||
// No DidTransactionCallback will be received, so mark the context clean
|
|
||||||
// now so future invalidations will be dispatched.
|
|
||||||
MarkContextClean();
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!mResetLayer && aOldLayer) {
|
|
||||||
RefPtr<Layer> ret = aOldLayer;
|
|
||||||
return ret.forget();
|
|
||||||
}
|
|
||||||
|
|
||||||
RefPtr<CanvasLayer> canvasLayer = aManager->CreateCanvasLayer();
|
|
||||||
if (!canvasLayer) {
|
|
||||||
NS_WARNING("CreateCanvasLayer returned null!");
|
|
||||||
// No DidTransactionCallback will be received, so mark the context clean
|
|
||||||
// now so future invalidations will be dispatched.
|
|
||||||
MarkContextClean();
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto canvasRenderer = canvasLayer->CreateOrGetCanvasRenderer();
|
|
||||||
InitializeCanvasRenderer(aBuilder, canvasRenderer);
|
|
||||||
uint32_t flags = mOpaque ? Layer::CONTENT_OPAQUE : 0;
|
|
||||||
canvasLayer->SetContentFlags(flags);
|
|
||||||
|
|
||||||
mResetLayer = false;
|
|
||||||
|
|
||||||
return canvasLayer.forget();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CanvasRenderingContext2D::UpdateWebRenderCanvasData(
|
bool CanvasRenderingContext2D::UpdateWebRenderCanvasData(
|
||||||
nsDisplayListBuilder* aBuilder, WebRenderCanvasData* aCanvasData) {
|
nsDisplayListBuilder* aBuilder, WebRenderCanvasData* aCanvasData) {
|
||||||
if (mOpaque) {
|
if (mOpaque) {
|
||||||
@@ -5491,11 +5448,6 @@ bool CanvasRenderingContext2D::IsContextCleanForFrameCapture() {
|
|||||||
return !mIsCapturedFrameInvalid;
|
return !mIsCapturedFrameInvalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CanvasRenderingContext2D::ShouldForceInactiveLayer(
|
|
||||||
LayerManager* aManager) {
|
|
||||||
return !aManager->CanUseCanvasLayerForSize(GetSize());
|
|
||||||
}
|
|
||||||
|
|
||||||
void CanvasRenderingContext2D::GetAppUnitsValues(int32_t* aPerDevPixel,
|
void CanvasRenderingContext2D::GetAppUnitsValues(int32_t* aPerDevPixel,
|
||||||
int32_t* aPerCSSPixel) {
|
int32_t* aPerCSSPixel) {
|
||||||
// If we don't have a canvas element, we just return something generic.
|
// If we don't have a canvas element, we just return something generic.
|
||||||
|
|||||||
@@ -422,16 +422,12 @@ class CanvasRenderingContext2D final : public nsICanvasRenderingContextInternal,
|
|||||||
virtual void SetOpaqueValueFromOpaqueAttr(bool aOpaqueAttrValue) override;
|
virtual void SetOpaqueValueFromOpaqueAttr(bool aOpaqueAttrValue) override;
|
||||||
bool GetIsOpaque() override { return mOpaque; }
|
bool GetIsOpaque() override { return mOpaque; }
|
||||||
NS_IMETHOD Reset() override;
|
NS_IMETHOD Reset() override;
|
||||||
already_AddRefed<Layer> GetCanvasLayer(nsDisplayListBuilder* aBuilder,
|
|
||||||
Layer* aOldLayer,
|
|
||||||
LayerManager* aManager) override;
|
|
||||||
|
|
||||||
bool UpdateWebRenderCanvasData(nsDisplayListBuilder* aBuilder,
|
bool UpdateWebRenderCanvasData(nsDisplayListBuilder* aBuilder,
|
||||||
WebRenderCanvasData* aCanvasData) override;
|
WebRenderCanvasData* aCanvasData) override;
|
||||||
|
|
||||||
bool InitializeCanvasRenderer(nsDisplayListBuilder* aBuilder,
|
bool InitializeCanvasRenderer(nsDisplayListBuilder* aBuilder,
|
||||||
CanvasRenderer* aRenderer) override;
|
CanvasRenderer* aRenderer) override;
|
||||||
virtual bool ShouldForceInactiveLayer(LayerManager* aManager) override;
|
|
||||||
void MarkContextClean() override;
|
void MarkContextClean() override;
|
||||||
void MarkContextCleanForFrameCapture() override;
|
void MarkContextCleanForFrameCapture() override;
|
||||||
bool IsContextCleanForFrameCapture() override;
|
bool IsContextCleanForFrameCapture() override;
|
||||||
|
|||||||
@@ -386,32 +386,6 @@ void ClientWebGLContext::ClearVRSwapChain() { Run<RPROC(ClearVRSwapChain)>(); }
|
|||||||
|
|
||||||
// -
|
// -
|
||||||
|
|
||||||
already_AddRefed<layers::Layer> ClientWebGLContext::GetCanvasLayer(
|
|
||||||
nsDisplayListBuilder* builder, Layer* oldLayer, LayerManager* manager) {
|
|
||||||
if (!mResetLayer && oldLayer) {
|
|
||||||
RefPtr<layers::Layer> ret = oldLayer;
|
|
||||||
return ret.forget();
|
|
||||||
}
|
|
||||||
|
|
||||||
RefPtr<CanvasLayer> canvasLayer = manager->CreateCanvasLayer();
|
|
||||||
if (!canvasLayer) {
|
|
||||||
NS_WARNING("CreateCanvasLayer returned null!");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto canvasRenderer = canvasLayer->CreateOrGetCanvasRenderer();
|
|
||||||
if (!InitializeCanvasRenderer(builder, canvasRenderer)) return nullptr;
|
|
||||||
|
|
||||||
uint32_t flags = 0;
|
|
||||||
if (GetIsOpaque()) {
|
|
||||||
flags |= Layer::CONTENT_OPAQUE;
|
|
||||||
}
|
|
||||||
canvasLayer->SetContentFlags(flags);
|
|
||||||
|
|
||||||
mResetLayer = false;
|
|
||||||
return canvasLayer.forget();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ClientWebGLContext::UpdateWebRenderCanvasData(
|
bool ClientWebGLContext::UpdateWebRenderCanvasData(
|
||||||
nsDisplayListBuilder* aBuilder, WebRenderCanvasData* aCanvasData) {
|
nsDisplayListBuilder* aBuilder, WebRenderCanvasData* aCanvasData) {
|
||||||
CanvasRenderer* renderer = aCanvasData->GetCanvasRenderer();
|
CanvasRenderer* renderer = aCanvasData->GetCanvasRenderer();
|
||||||
|
|||||||
@@ -909,9 +909,6 @@ class ClientWebGLContext final : public nsICanvasRenderingContextInternal,
|
|||||||
// nsICanvasRenderingContextInternal / nsAPostRefreshObserver
|
// nsICanvasRenderingContextInternal / nsAPostRefreshObserver
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
public:
|
public:
|
||||||
already_AddRefed<layers::Layer> GetCanvasLayer(
|
|
||||||
nsDisplayListBuilder* builder, layers::Layer* oldLayer,
|
|
||||||
layers::LayerManager* manager) override;
|
|
||||||
bool InitializeCanvasRenderer(nsDisplayListBuilder* aBuilder,
|
bool InitializeCanvasRenderer(nsDisplayListBuilder* aBuilder,
|
||||||
layers::CanvasRenderer* aRenderer) override;
|
layers::CanvasRenderer* aRenderer) override;
|
||||||
// Note that 'clean' here refers to its invalidation state, not the
|
// Note that 'clean' here refers to its invalidation state, not the
|
||||||
|
|||||||
@@ -4,10 +4,11 @@
|
|||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
#include "ImageBitmapRenderingContext.h"
|
#include "ImageBitmapRenderingContext.h"
|
||||||
|
#include "gfxPlatform.h"
|
||||||
#include "mozilla/dom/ImageBitmapRenderingContextBinding.h"
|
#include "mozilla/dom/ImageBitmapRenderingContextBinding.h"
|
||||||
#include "nsComponentManagerUtils.h"
|
#include "nsComponentManagerUtils.h"
|
||||||
|
#include "nsRegion.h"
|
||||||
#include "ImageContainer.h"
|
#include "ImageContainer.h"
|
||||||
#include "ImageLayers.h"
|
|
||||||
|
|
||||||
namespace mozilla::dom {
|
namespace mozilla::dom {
|
||||||
|
|
||||||
@@ -198,40 +199,6 @@ ImageBitmapRenderingContext::Reset() {
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<layers::Layer> ImageBitmapRenderingContext::GetCanvasLayer(
|
|
||||||
nsDisplayListBuilder* aBuilder, Layer* aOldLayer, LayerManager* aManager) {
|
|
||||||
if (!mImage) {
|
|
||||||
// No DidTransactionCallback will be received, so mark the context clean
|
|
||||||
// now so future invalidations will be dispatched.
|
|
||||||
MarkContextClean();
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
RefPtr<layers::ImageLayer> imageLayer;
|
|
||||||
|
|
||||||
if (aOldLayer) {
|
|
||||||
imageLayer = static_cast<layers::ImageLayer*>(aOldLayer);
|
|
||||||
} else {
|
|
||||||
imageLayer = aManager->CreateImageLayer();
|
|
||||||
}
|
|
||||||
|
|
||||||
RefPtr<layers::ImageContainer> imageContainer = imageLayer->GetContainer();
|
|
||||||
if (!imageContainer) {
|
|
||||||
imageContainer = LayerManager::CreateImageContainer();
|
|
||||||
imageLayer->SetContainer(imageContainer);
|
|
||||||
}
|
|
||||||
|
|
||||||
AutoTArray<layers::ImageContainer::NonOwningImage, 1> imageList;
|
|
||||||
RefPtr<layers::Image> image = ClipToIntrinsicSize();
|
|
||||||
if (!image) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
imageList.AppendElement(layers::ImageContainer::NonOwningImage(image));
|
|
||||||
imageContainer->SetCurrentImages(imageList);
|
|
||||||
|
|
||||||
return imageLayer.forget();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ImageBitmapRenderingContext::UpdateWebRenderCanvasData(
|
bool ImageBitmapRenderingContext::UpdateWebRenderCanvasData(
|
||||||
nsDisplayListBuilder* aBuilder, WebRenderCanvasData* aCanvasData) {
|
nsDisplayListBuilder* aBuilder, WebRenderCanvasData* aCanvasData) {
|
||||||
if (!mImage) {
|
if (!mImage) {
|
||||||
|
|||||||
@@ -78,9 +78,6 @@ class ImageBitmapRenderingContext final
|
|||||||
virtual void SetOpaqueValueFromOpaqueAttr(bool aOpaqueAttrValue) override;
|
virtual void SetOpaqueValueFromOpaqueAttr(bool aOpaqueAttrValue) override;
|
||||||
virtual bool GetIsOpaque() override;
|
virtual bool GetIsOpaque() override;
|
||||||
NS_IMETHOD Reset() override;
|
NS_IMETHOD Reset() override;
|
||||||
virtual already_AddRefed<Layer> GetCanvasLayer(
|
|
||||||
nsDisplayListBuilder* aBuilder, Layer* aOldLayer,
|
|
||||||
LayerManager* aManager) override;
|
|
||||||
virtual already_AddRefed<layers::Image> GetAsImage() override {
|
virtual already_AddRefed<layers::Image> GetAsImage() override {
|
||||||
return ClipToIntrinsicSize();
|
return ClipToIntrinsicSize();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -470,10 +470,6 @@ class WebGLContext : public VRefCounted, public SupportsWeakPtr {
|
|||||||
|
|
||||||
WebGLTexture* GetActiveTex(const GLenum texTarget) const;
|
WebGLTexture* GetActiveTex(const GLenum texTarget) const;
|
||||||
|
|
||||||
already_AddRefed<layers::Layer> GetCanvasLayer(nsDisplayListBuilder* builder,
|
|
||||||
layers::Layer* oldLayer,
|
|
||||||
layers::LayerManager* manager);
|
|
||||||
|
|
||||||
Maybe<ICRData> InitializeCanvasRenderer(layers::LayersBackend backend);
|
Maybe<ICRData> InitializeCanvasRenderer(layers::LayersBackend backend);
|
||||||
|
|
||||||
gl::GLContext* GL() const { return gl; }
|
gl::GLContext* GL() const { return gl; }
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ class nsDisplayListBuilder;
|
|||||||
class ClientWebGLContext;
|
class ClientWebGLContext;
|
||||||
class PresShell;
|
class PresShell;
|
||||||
namespace layers {
|
namespace layers {
|
||||||
class CanvasLayer;
|
|
||||||
class CanvasRenderer;
|
class CanvasRenderer;
|
||||||
class CompositableHandle;
|
class CompositableHandle;
|
||||||
class Layer;
|
class Layer;
|
||||||
@@ -53,7 +52,6 @@ class SourceSurface;
|
|||||||
class nsICanvasRenderingContextInternal : public nsISupports,
|
class nsICanvasRenderingContextInternal : public nsISupports,
|
||||||
public nsAPostRefreshObserver {
|
public nsAPostRefreshObserver {
|
||||||
public:
|
public:
|
||||||
using CanvasLayer = mozilla::layers::CanvasLayer;
|
|
||||||
using CanvasRenderer = mozilla::layers::CanvasRenderer;
|
using CanvasRenderer = mozilla::layers::CanvasRenderer;
|
||||||
using Layer = mozilla::layers::Layer;
|
using Layer = mozilla::layers::Layer;
|
||||||
using LayerManager = mozilla::layers::LayerManager;
|
using LayerManager = mozilla::layers::LayerManager;
|
||||||
@@ -142,11 +140,6 @@ class nsICanvasRenderingContextInternal : public nsISupports,
|
|||||||
// for possibly reinitializing with SetDimensions/InitializeWithSurface.
|
// for possibly reinitializing with SetDimensions/InitializeWithSurface.
|
||||||
NS_IMETHOD Reset() = 0;
|
NS_IMETHOD Reset() = 0;
|
||||||
|
|
||||||
// Return the CanvasLayer for this context, creating
|
|
||||||
// one for the given layer manager if not available.
|
|
||||||
virtual already_AddRefed<Layer> GetCanvasLayer(
|
|
||||||
mozilla::nsDisplayListBuilder* builder, Layer* oldLayer,
|
|
||||||
LayerManager* manager) = 0;
|
|
||||||
virtual already_AddRefed<mozilla::layers::Image> GetAsImage() {
|
virtual already_AddRefed<mozilla::layers::Image> GetAsImage() {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@@ -160,11 +153,6 @@ class nsICanvasRenderingContextInternal : public nsISupports,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return true if the canvas should be forced to be "inactive" to ensure
|
|
||||||
// it can be drawn to the screen even if it's too large to be blitted by
|
|
||||||
// an accelerated CanvasLayer.
|
|
||||||
virtual bool ShouldForceInactiveLayer(LayerManager* manager) { return false; }
|
|
||||||
|
|
||||||
virtual void MarkContextClean() = 0;
|
virtual void MarkContextClean() = 0;
|
||||||
|
|
||||||
// Called when a frame is captured.
|
// Called when a frame is captured.
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
#include "mozilla/dom/HTMLCanvasElement.h"
|
#include "mozilla/dom/HTMLCanvasElement.h"
|
||||||
|
|
||||||
#include "ImageEncoder.h"
|
#include "ImageEncoder.h"
|
||||||
#include "ImageLayers.h"
|
|
||||||
#include "jsapi.h"
|
#include "jsapi.h"
|
||||||
#include "jsfriendapi.h"
|
#include "jsfriendapi.h"
|
||||||
#include "Layers.h"
|
#include "Layers.h"
|
||||||
@@ -1076,11 +1075,7 @@ void HTMLCanvasElement::InvalidateCanvasContent(const gfx::Rect* damageRect) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (layer) {
|
if (layer) {
|
||||||
if (CanvasLayer* canvas = layer->AsCanvasLayer()) {
|
|
||||||
canvas->Updated();
|
|
||||||
} else {
|
|
||||||
layer->SetInvalidRectToVisibleRegion();
|
layer->SetInvalidRectToVisibleRegion();
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// This path is taken in two situations:
|
// This path is taken in two situations:
|
||||||
// 1) WebRender is enabled and has not yet processed a display list.
|
// 1) WebRender is enabled and has not yet processed a display list.
|
||||||
@@ -1129,19 +1124,6 @@ CanvasContextType HTMLCanvasElement::GetCurrentContextType() {
|
|||||||
return mCurrentContextType;
|
return mCurrentContextType;
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<Layer> HTMLCanvasElement::GetCanvasLayer(
|
|
||||||
nsDisplayListBuilder* aBuilder, Layer* aOldLayer, LayerManager* aManager) {
|
|
||||||
if (mCurrentContext) {
|
|
||||||
return mCurrentContext->GetCanvasLayer(aBuilder, aOldLayer, aManager);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mOffscreenCanvas) {
|
|
||||||
MOZ_CRASH("todo");
|
|
||||||
}
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
already_AddRefed<Image> HTMLCanvasElement::GetAsImage() {
|
already_AddRefed<Image> HTMLCanvasElement::GetAsImage() {
|
||||||
if (mCurrentContext) {
|
if (mCurrentContext) {
|
||||||
return mCurrentContext->GetAsImage();
|
return mCurrentContext->GetAsImage();
|
||||||
@@ -1181,19 +1163,6 @@ bool HTMLCanvasElement::InitializeCanvasRenderer(nsDisplayListBuilder* aBuilder,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HTMLCanvasElement::ShouldForceInactiveLayer(LayerManager* aManager) {
|
|
||||||
if (mCurrentContext) {
|
|
||||||
return mCurrentContext->ShouldForceInactiveLayer(aManager);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mOffscreenCanvas) {
|
|
||||||
// TODO: We should handle offscreen canvas case.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void HTMLCanvasElement::MarkContextClean() {
|
void HTMLCanvasElement::MarkContextClean() {
|
||||||
if (!mCurrentContext) return;
|
if (!mCurrentContext) return;
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ class ClientWebGLContext;
|
|||||||
|
|
||||||
namespace layers {
|
namespace layers {
|
||||||
class CanvasRenderer;
|
class CanvasRenderer;
|
||||||
class CanvasLayer;
|
|
||||||
class Image;
|
class Image;
|
||||||
class Layer;
|
class Layer;
|
||||||
class LayerManager;
|
class LayerManager;
|
||||||
@@ -122,7 +121,6 @@ class HTMLCanvasElement final : public nsGenericHTMLElement,
|
|||||||
enum { DEFAULT_CANVAS_WIDTH = 300, DEFAULT_CANVAS_HEIGHT = 150 };
|
enum { DEFAULT_CANVAS_WIDTH = 300, DEFAULT_CANVAS_HEIGHT = 150 };
|
||||||
|
|
||||||
typedef layers::CanvasRenderer CanvasRenderer;
|
typedef layers::CanvasRenderer CanvasRenderer;
|
||||||
typedef layers::CanvasLayer CanvasLayer;
|
|
||||||
typedef layers::Layer Layer;
|
typedef layers::Layer Layer;
|
||||||
typedef layers::LayerManager LayerManager;
|
typedef layers::LayerManager LayerManager;
|
||||||
typedef layers::WebRenderCanvasData WebRenderCanvasData;
|
typedef layers::WebRenderCanvasData WebRenderCanvasData;
|
||||||
@@ -298,18 +296,11 @@ class HTMLCanvasElement final : public nsGenericHTMLElement,
|
|||||||
* Helpers called by various users of Canvas
|
* Helpers called by various users of Canvas
|
||||||
*/
|
*/
|
||||||
|
|
||||||
already_AddRefed<Layer> GetCanvasLayer(nsDisplayListBuilder* aBuilder,
|
|
||||||
Layer* aOldLayer,
|
|
||||||
LayerManager* aManager);
|
|
||||||
already_AddRefed<layers::Image> GetAsImage();
|
already_AddRefed<layers::Image> GetAsImage();
|
||||||
bool UpdateWebRenderCanvasData(nsDisplayListBuilder* aBuilder,
|
bool UpdateWebRenderCanvasData(nsDisplayListBuilder* aBuilder,
|
||||||
WebRenderCanvasData* aCanvasData);
|
WebRenderCanvasData* aCanvasData);
|
||||||
bool InitializeCanvasRenderer(nsDisplayListBuilder* aBuilder,
|
bool InitializeCanvasRenderer(nsDisplayListBuilder* aBuilder,
|
||||||
CanvasRenderer* aRenderer);
|
CanvasRenderer* aRenderer);
|
||||||
// Should return true if the canvas layer should always be marked inactive.
|
|
||||||
// We should return true here if we can't do accelerated compositing with
|
|
||||||
// a non-BasicCanvasLayer.
|
|
||||||
bool ShouldForceInactiveLayer(LayerManager* aManager);
|
|
||||||
|
|
||||||
// Call this whenever we need future changes to the canvas
|
// Call this whenever we need future changes to the canvas
|
||||||
// to trigger fresh invalidation requests. This needs to be called
|
// to trigger fresh invalidation requests. This needs to be called
|
||||||
|
|||||||
@@ -53,12 +53,6 @@ JSObject* CanvasContext::WrapObject(JSContext* aCx,
|
|||||||
return dom::GPUCanvasContext_Binding::Wrap(aCx, this, aGivenProto);
|
return dom::GPUCanvasContext_Binding::Wrap(aCx, this, aGivenProto);
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<layers::Layer> CanvasContext::GetCanvasLayer(
|
|
||||||
nsDisplayListBuilder* aBuilder, layers::Layer* aOldLayer,
|
|
||||||
layers::LayerManager* aManager) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CanvasContext::UpdateWebRenderCanvasData(
|
bool CanvasContext::UpdateWebRenderCanvasData(
|
||||||
nsDisplayListBuilder* aBuilder, WebRenderCanvasData* aCanvasData) {
|
nsDisplayListBuilder* aBuilder, WebRenderCanvasData* aCanvasData) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -81,9 +81,6 @@ class CanvasContext final : public nsICanvasRenderingContextInternal,
|
|||||||
void SetOpaqueValueFromOpaqueAttr(bool aOpaqueAttrValue) override {}
|
void SetOpaqueValueFromOpaqueAttr(bool aOpaqueAttrValue) override {}
|
||||||
bool GetIsOpaque() override { return true; }
|
bool GetIsOpaque() override { return true; }
|
||||||
NS_IMETHOD Reset() override { return NS_OK; }
|
NS_IMETHOD Reset() override { return NS_OK; }
|
||||||
already_AddRefed<Layer> GetCanvasLayer(nsDisplayListBuilder* aBuilder,
|
|
||||||
Layer* aOldLayer,
|
|
||||||
LayerManager* aManager) override;
|
|
||||||
bool UpdateWebRenderCanvasData(nsDisplayListBuilder* aBuilder,
|
bool UpdateWebRenderCanvasData(nsDisplayListBuilder* aBuilder,
|
||||||
WebRenderCanvasData* aCanvasData) override;
|
WebRenderCanvasData* aCanvasData) override;
|
||||||
void MarkContextClean() override {}
|
void MarkContextClean() override {}
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ class nsICanvasRenderingContextInternal;
|
|||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace layers {
|
namespace layers {
|
||||||
|
|
||||||
class ClientCanvasRenderer;
|
|
||||||
class KnowsCompositor;
|
class KnowsCompositor;
|
||||||
class PersistentBufferProvider;
|
class PersistentBufferProvider;
|
||||||
class WebRenderCanvasRendererAsync;
|
class WebRenderCanvasRendererAsync;
|
||||||
@@ -64,8 +63,6 @@ struct CanvasRendererData final {
|
|||||||
// different in different LayerManager. So that we have following classes
|
// different in different LayerManager. So that we have following classes
|
||||||
// inherit ShareableCanvasRenderer.
|
// inherit ShareableCanvasRenderer.
|
||||||
//
|
//
|
||||||
// ClientCanvasRenderer inherits ShareableCanvasRenderer and be used in
|
|
||||||
// ClientCanvasLayer.
|
|
||||||
// WebRenderCanvasRenderer inherits ShareableCanvasRenderer and provides all
|
// WebRenderCanvasRenderer inherits ShareableCanvasRenderer and provides all
|
||||||
// functionality that WebRender uses.
|
// functionality that WebRender uses.
|
||||||
// WebRenderCanvasRendererAsync inherits WebRenderCanvasRenderer and be used in
|
// WebRenderCanvasRendererAsync inherits WebRenderCanvasRenderer and be used in
|
||||||
@@ -81,12 +78,11 @@ struct CanvasRendererData final {
|
|||||||
// +-----------+-----------+
|
// +-----------+-----------+
|
||||||
// |ShareableCanvasRenderer|
|
// |ShareableCanvasRenderer|
|
||||||
// +-----+-----------------+
|
// +-----+-----------------+
|
||||||
// ^ ^
|
// ^
|
||||||
// +-------------+ +-------+
|
// |
|
||||||
// | |
|
// +-----------+-----------+
|
||||||
// +--------------------+ +---------+-------------+
|
// |WebRenderCanvasRenderer|
|
||||||
// |ClientCanvasRenderer| |WebRenderCanvasRenderer|
|
// +-----------+-----------+
|
||||||
// +--------------------+ +-----------+-----------+
|
|
||||||
// ^
|
// ^
|
||||||
// |
|
// |
|
||||||
// +-------------+--------------+
|
// +-------------+--------------+
|
||||||
@@ -135,7 +131,6 @@ class CanvasRenderer : public RefCounted<CanvasRenderer> {
|
|||||||
void ResetDirty() { mDirty = false; }
|
void ResetDirty() { mDirty = false; }
|
||||||
bool IsDirty() const { return mDirty; }
|
bool IsDirty() const { return mDirty; }
|
||||||
|
|
||||||
virtual ClientCanvasRenderer* AsClientCanvasRenderer() { return nullptr; }
|
|
||||||
virtual WebRenderCanvasRendererAsync* AsWebRenderCanvasRendererAsync() {
|
virtual WebRenderCanvasRendererAsync* AsWebRenderCanvasRendererAsync() {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -199,11 +199,6 @@ class Compositor : public TextureSourceProvider {
|
|||||||
*/
|
*/
|
||||||
virtual TextureFactoryIdentifier GetTextureFactoryIdentifier() = 0;
|
virtual TextureFactoryIdentifier GetTextureFactoryIdentifier() = 0;
|
||||||
|
|
||||||
/**
|
|
||||||
* Properties of the compositor.
|
|
||||||
*/
|
|
||||||
virtual bool CanUseCanvasLayerForSize(const gfx::IntSize& aSize) = 0;
|
|
||||||
|
|
||||||
typedef uint32_t MakeCurrentFlags;
|
typedef uint32_t MakeCurrentFlags;
|
||||||
static const MakeCurrentFlags ForceMakeCurrent = 0x1;
|
static const MakeCurrentFlags ForceMakeCurrent = 0x1;
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,61 +0,0 @@
|
|||||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
||||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
||||||
/* 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/. */
|
|
||||||
|
|
||||||
#include "ImageLayers.h"
|
|
||||||
#include "ImageContainer.h" // for ImageContainer
|
|
||||||
#include "gfxRect.h" // for gfxRect
|
|
||||||
#include "nsDebug.h" // for NS_ASSERTION
|
|
||||||
#include "nsISupportsImpl.h" // for ImageContainer::Release, etc
|
|
||||||
#include "gfx2DGlue.h"
|
|
||||||
|
|
||||||
namespace mozilla {
|
|
||||||
namespace layers {
|
|
||||||
|
|
||||||
ImageLayer::ImageLayer(LayerManager* aManager, void* aImplData)
|
|
||||||
: Layer(aManager, aImplData),
|
|
||||||
mSamplingFilter(gfx::SamplingFilter::GOOD),
|
|
||||||
mScaleMode(ScaleMode::SCALE_NONE) {}
|
|
||||||
|
|
||||||
ImageLayer::~ImageLayer() = default;
|
|
||||||
|
|
||||||
void ImageLayer::SetContainer(ImageContainer* aContainer) {
|
|
||||||
mContainer = aContainer;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImageLayer::ComputeEffectiveTransforms(
|
|
||||||
const gfx::Matrix4x4& aTransformToSurface) {
|
|
||||||
gfx::Matrix4x4 local = GetLocalTransform();
|
|
||||||
|
|
||||||
// Snap image edges to pixel boundaries
|
|
||||||
gfxRect sourceRect(0, 0, 0, 0);
|
|
||||||
if (mContainer) {
|
|
||||||
sourceRect.SizeTo(gfx::SizeDouble(mContainer->GetCurrentSize()));
|
|
||||||
}
|
|
||||||
// Snap our local transform first, and snap the inherited transform as well.
|
|
||||||
// This makes our snapping equivalent to what would happen if our content
|
|
||||||
// was drawn into a PaintedLayer (gfxContext would snap using the local
|
|
||||||
// transform, then we'd snap again when compositing the PaintedLayer).
|
|
||||||
mEffectiveTransform = SnapTransform(local, sourceRect, nullptr) *
|
|
||||||
SnapTransformTranslation(aTransformToSurface, nullptr);
|
|
||||||
|
|
||||||
if (mScaleMode != ScaleMode::SCALE_NONE && !sourceRect.IsZeroArea()) {
|
|
||||||
NS_ASSERTION(mScaleMode == ScaleMode::STRETCH,
|
|
||||||
"No other scalemodes than stretch and none supported yet.");
|
|
||||||
local.PreScale(mScaleToSize.width / sourceRect.Width(),
|
|
||||||
mScaleToSize.height / sourceRect.Height(), 1.0);
|
|
||||||
|
|
||||||
mEffectiveTransformForBuffer =
|
|
||||||
SnapTransform(local, sourceRect, nullptr) *
|
|
||||||
SnapTransformTranslation(aTransformToSurface, nullptr);
|
|
||||||
} else {
|
|
||||||
mEffectiveTransformForBuffer = mEffectiveTransform;
|
|
||||||
}
|
|
||||||
|
|
||||||
ComputeEffectiveTransformForMaskLayers(aTransformToSurface);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace layers
|
|
||||||
} // namespace mozilla
|
|
||||||
@@ -1,88 +0,0 @@
|
|||||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
||||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
||||||
/* 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 GFX_IMAGELAYER_H
|
|
||||||
#define GFX_IMAGELAYER_H
|
|
||||||
|
|
||||||
#include "Layers.h" // for Layer, etc
|
|
||||||
#include "mozilla/gfx/BaseSize.h" // for BaseSize
|
|
||||||
#include "mozilla/gfx/Point.h" // for IntSize
|
|
||||||
#include "mozilla/layers/LayersTypes.h"
|
|
||||||
#include "nscore.h" // for nsACString
|
|
||||||
|
|
||||||
namespace mozilla {
|
|
||||||
namespace layers {
|
|
||||||
|
|
||||||
class ImageContainer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A Layer which renders an Image.
|
|
||||||
*/
|
|
||||||
class ImageLayer : public Layer {
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* CONSTRUCTION PHASE ONLY
|
|
||||||
* Set the ImageContainer. aContainer must have the same layer manager
|
|
||||||
* as this layer.
|
|
||||||
*/
|
|
||||||
virtual void SetContainer(ImageContainer* aContainer);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CONSTRUCTION PHASE ONLY
|
|
||||||
* Set the filter used to resample this image if necessary.
|
|
||||||
*/
|
|
||||||
void SetSamplingFilter(gfx::SamplingFilter aSamplingFilter) {
|
|
||||||
if (mSamplingFilter != aSamplingFilter) {
|
|
||||||
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) Filter", this));
|
|
||||||
mSamplingFilter = aSamplingFilter;
|
|
||||||
Mutated();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CONSTRUCTION PHASE ONLY
|
|
||||||
* Set the size to scale the image to and the mode at which to scale.
|
|
||||||
*/
|
|
||||||
void SetScaleToSize(const gfx::IntSize& aSize, ScaleMode aMode) {
|
|
||||||
if (mScaleToSize != aSize || mScaleMode != aMode) {
|
|
||||||
mScaleToSize = aSize;
|
|
||||||
mScaleMode = aMode;
|
|
||||||
Mutated();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ImageContainer* GetContainer() { return mContainer; }
|
|
||||||
gfx::SamplingFilter GetSamplingFilter() { return mSamplingFilter; }
|
|
||||||
const gfx::IntSize& GetScaleToSize() { return mScaleToSize; }
|
|
||||||
ScaleMode GetScaleMode() { return mScaleMode; }
|
|
||||||
|
|
||||||
MOZ_LAYER_DECL_NAME("ImageLayer", TYPE_IMAGE)
|
|
||||||
|
|
||||||
void ComputeEffectiveTransforms(
|
|
||||||
const gfx::Matrix4x4& aTransformToSurface) override;
|
|
||||||
|
|
||||||
const gfx::Matrix4x4& GetEffectiveTransformForBuffer() const override {
|
|
||||||
return mEffectiveTransformForBuffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
ImageLayer* AsImageLayer() override { return this; }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
ImageLayer(LayerManager* aManager, void* aImplData);
|
|
||||||
virtual ~ImageLayer();
|
|
||||||
void PrintInfo(std::stringstream& aStream, const char* aPrefix) override;
|
|
||||||
|
|
||||||
RefPtr<ImageContainer> mContainer;
|
|
||||||
gfx::SamplingFilter mSamplingFilter;
|
|
||||||
gfx::IntSize mScaleToSize;
|
|
||||||
ScaleMode mScaleMode;
|
|
||||||
gfx::Matrix4x4 mEffectiveTransformForBuffer;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace layers
|
|
||||||
} // namespace mozilla
|
|
||||||
|
|
||||||
#endif /* GFX_IMAGELAYER_H */
|
|
||||||
@@ -61,10 +61,8 @@ class Layer;
|
|||||||
class LayerMetricsWrapper;
|
class LayerMetricsWrapper;
|
||||||
class PaintedLayer;
|
class PaintedLayer;
|
||||||
class ContainerLayer;
|
class ContainerLayer;
|
||||||
class ImageLayer;
|
|
||||||
class ColorLayer;
|
class ColorLayer;
|
||||||
class CompositorBridgeChild;
|
class CompositorBridgeChild;
|
||||||
class CanvasLayer;
|
|
||||||
class ReadbackLayer;
|
class ReadbackLayer;
|
||||||
class ReadbackProcessor;
|
class ReadbackProcessor;
|
||||||
class RefLayer;
|
class RefLayer;
|
||||||
@@ -325,21 +323,11 @@ class LayerManager : public WindowRenderer {
|
|||||||
* Create a ContainerLayer for this manager's layer tree.
|
* Create a ContainerLayer for this manager's layer tree.
|
||||||
*/
|
*/
|
||||||
virtual already_AddRefed<ContainerLayer> CreateContainerLayer() = 0;
|
virtual already_AddRefed<ContainerLayer> CreateContainerLayer() = 0;
|
||||||
/**
|
|
||||||
* CONSTRUCTION PHASE ONLY
|
|
||||||
* Create an ImageLayer for this manager's layer tree.
|
|
||||||
*/
|
|
||||||
virtual already_AddRefed<ImageLayer> CreateImageLayer() = 0;
|
|
||||||
/**
|
/**
|
||||||
* CONSTRUCTION PHASE ONLY
|
* CONSTRUCTION PHASE ONLY
|
||||||
* Create a ColorLayer for this manager's layer tree.
|
* Create a ColorLayer for this manager's layer tree.
|
||||||
*/
|
*/
|
||||||
virtual already_AddRefed<ColorLayer> CreateColorLayer() = 0;
|
virtual already_AddRefed<ColorLayer> CreateColorLayer() = 0;
|
||||||
/**
|
|
||||||
* CONSTRUCTION PHASE ONLY
|
|
||||||
* Create a CanvasLayer for this manager's layer tree.
|
|
||||||
*/
|
|
||||||
virtual already_AddRefed<CanvasLayer> CreateCanvasLayer() = 0;
|
|
||||||
/**
|
/**
|
||||||
* CONSTRUCTION PHASE ONLY
|
* CONSTRUCTION PHASE ONLY
|
||||||
* Create a ReadbackLayer for this manager's layer tree.
|
* Create a ReadbackLayer for this manager's layer tree.
|
||||||
@@ -387,10 +375,6 @@ class LayerManager : public WindowRenderer {
|
|||||||
virtual already_AddRefed<mozilla::gfx::DrawTarget> CreateDrawTarget(
|
virtual already_AddRefed<mozilla::gfx::DrawTarget> CreateDrawTarget(
|
||||||
const mozilla::gfx::IntSize& aSize, mozilla::gfx::SurfaceFormat aFormat);
|
const mozilla::gfx::IntSize& aSize, mozilla::gfx::SurfaceFormat aFormat);
|
||||||
|
|
||||||
virtual bool CanUseCanvasLayerForSize(const gfx::IntSize& aSize) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This setter can be used anytime. The user data for all keys is
|
* This setter can be used anytime. The user data for all keys is
|
||||||
* initially null. Ownership pases to the layer manager.
|
* initially null. Ownership pases to the layer manager.
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
#include <type_traits> // for remove_reference<>::type
|
#include <type_traits> // for remove_reference<>::type
|
||||||
#include "CompositableHost.h" // for CompositableHost
|
#include "CompositableHost.h" // for CompositableHost
|
||||||
#include "GeckoProfiler.h" // for profiler_can_accept_markers, PROFILER_MARKER_TEXT
|
#include "GeckoProfiler.h" // for profiler_can_accept_markers, PROFILER_MARKER_TEXT
|
||||||
#include "ImageLayers.h" // for ImageLayer
|
|
||||||
#include "LayerUserData.h" // for LayerUserData
|
#include "LayerUserData.h" // for LayerUserData
|
||||||
#include "ReadbackLayer.h" // for ReadbackLayer
|
#include "ReadbackLayer.h" // for ReadbackLayer
|
||||||
#include "TreeTraversal.h" // for ForwardIterator, ForEachNode, DepthFirstSearch, TraversalFlag, TraversalFl...
|
#include "TreeTraversal.h" // for ForwardIterator, ForEachNode, DepthFirstSearch, TraversalFlag, TraversalFl...
|
||||||
@@ -1355,33 +1354,6 @@ void ColorLayer::PrintInfo(std::stringstream& aStream, const char* aPrefix) {
|
|||||||
aStream << " [color=" << mColor << "] [bounds=" << mBounds << "]";
|
aStream << " [color=" << mColor << "] [bounds=" << mBounds << "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
CanvasLayer::CanvasLayer(LayerManager* aManager, void* aImplData)
|
|
||||||
: Layer(aManager, aImplData), mSamplingFilter(SamplingFilter::GOOD) {}
|
|
||||||
|
|
||||||
CanvasLayer::~CanvasLayer() = default;
|
|
||||||
|
|
||||||
void CanvasLayer::PrintInfo(std::stringstream& aStream, const char* aPrefix) {
|
|
||||||
Layer::PrintInfo(aStream, aPrefix);
|
|
||||||
if (mSamplingFilter != SamplingFilter::GOOD) {
|
|
||||||
aStream << " [filter=" << mSamplingFilter << "]";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RefPtr<CanvasRenderer> CanvasLayer::CreateOrGetCanvasRenderer() {
|
|
||||||
if (!mCanvasRenderer) {
|
|
||||||
mCanvasRenderer = CreateCanvasRendererInternal();
|
|
||||||
}
|
|
||||||
|
|
||||||
return mCanvasRenderer;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImageLayer::PrintInfo(std::stringstream& aStream, const char* aPrefix) {
|
|
||||||
Layer::PrintInfo(aStream, aPrefix);
|
|
||||||
if (mSamplingFilter != SamplingFilter::GOOD) {
|
|
||||||
aStream << " [filter=" << mSamplingFilter << "]";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RefLayer::PrintInfo(std::stringstream& aStream, const char* aPrefix) {
|
void RefLayer::PrintInfo(std::stringstream& aStream, const char* aPrefix) {
|
||||||
ContainerLayer::PrintInfo(aStream, aPrefix);
|
ContainerLayer::PrintInfo(aStream, aPrefix);
|
||||||
if (mId.IsValid()) {
|
if (mId.IsValid()) {
|
||||||
|
|||||||
@@ -49,7 +49,6 @@
|
|||||||
#include "gfx2DGlue.h" // for ThebesPoint
|
#include "gfx2DGlue.h" // for ThebesPoint
|
||||||
#include "mozilla/Assertions.h" // for AssertionConditionType, MOZ_ASSERT, MOZ_A...
|
#include "mozilla/Assertions.h" // for AssertionConditionType, MOZ_ASSERT, MOZ_A...
|
||||||
#include "mozilla/DebugOnly.h" // for DebugOnly
|
#include "mozilla/DebugOnly.h" // for DebugOnly
|
||||||
#include "mozilla/layers/CanvasRenderer.h" // for CanvasRenderer
|
|
||||||
#include "mozilla/layers/LayersTypes.h" // for MOZ_LAYERS_LOG_IF_SHADOWABLE, LayersId, EventRegionsO...
|
#include "mozilla/layers/LayersTypes.h" // for MOZ_LAYERS_LOG_IF_SHADOWABLE, LayersId, EventRegionsO...
|
||||||
#include "nsDebug.h" // for NS_ASSERTION, NS_WARNING
|
#include "nsDebug.h" // for NS_ASSERTION, NS_WARNING
|
||||||
|
|
||||||
@@ -67,10 +66,8 @@ class Animation;
|
|||||||
class AsyncPanZoomController;
|
class AsyncPanZoomController;
|
||||||
class PaintedLayer;
|
class PaintedLayer;
|
||||||
class ContainerLayer;
|
class ContainerLayer;
|
||||||
class ImageLayer;
|
|
||||||
class ColorLayer;
|
class ColorLayer;
|
||||||
class CompositorAnimations;
|
class CompositorAnimations;
|
||||||
class CanvasLayer;
|
|
||||||
class RefLayer;
|
class RefLayer;
|
||||||
class SpecificLayerAttributes;
|
class SpecificLayerAttributes;
|
||||||
class Compositor;
|
class Compositor;
|
||||||
@@ -880,18 +877,6 @@ class Layer {
|
|||||||
*/
|
*/
|
||||||
virtual ColorLayer* AsColorLayer() { return nullptr; }
|
virtual ColorLayer* AsColorLayer() { return nullptr; }
|
||||||
|
|
||||||
/**
|
|
||||||
* Dynamic cast to a Canvas. Returns null if this is not a
|
|
||||||
* ColorLayer.
|
|
||||||
*/
|
|
||||||
virtual CanvasLayer* AsCanvasLayer() { return nullptr; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Dynamic cast to an Image. Returns null if this is not a
|
|
||||||
* ColorLayer.
|
|
||||||
*/
|
|
||||||
virtual ImageLayer* AsImageLayer() { return nullptr; }
|
|
||||||
|
|
||||||
// These getters can be used anytime. They return the effective
|
// These getters can be used anytime. They return the effective
|
||||||
// values that should be used when drawing this layer to screen,
|
// values that should be used when drawing this layer to screen,
|
||||||
// accounting for this layer possibly being a shadow.
|
// accounting for this layer possibly being a shadow.
|
||||||
@@ -1727,101 +1712,6 @@ class ColorLayer : public Layer {
|
|||||||
gfx::DeviceColor mColor;
|
gfx::DeviceColor mColor;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* A Layer for HTML Canvas elements. It's backed by either a
|
|
||||||
* gfxASurface or a GLContext (for WebGL layers), and has some control
|
|
||||||
* for intelligent updating from the source if necessary (for example,
|
|
||||||
* if hardware compositing is not available, for reading from the GL
|
|
||||||
* buffer into an image surface that we can layer composite.)
|
|
||||||
*
|
|
||||||
* After Initialize is called, the underlying canvas Surface/GLContext
|
|
||||||
* must not be modified during a layer transaction.
|
|
||||||
*/
|
|
||||||
class CanvasLayer : public Layer {
|
|
||||||
public:
|
|
||||||
void SetBounds(gfx::IntRect aBounds) { mBounds = aBounds; }
|
|
||||||
|
|
||||||
CanvasLayer* AsCanvasLayer() override { return this; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Notify this CanvasLayer that the canvas surface contents have
|
|
||||||
* changed (or will change) before the next transaction.
|
|
||||||
*/
|
|
||||||
void Updated() {
|
|
||||||
mCanvasRenderer->SetDirty();
|
|
||||||
SetInvalidRectToVisibleRegion();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Notify this CanvasLayer that the canvas surface contents have
|
|
||||||
* been painted since the last change.
|
|
||||||
*/
|
|
||||||
void Painted() { mCanvasRenderer->ResetDirty(); }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if the canvas surface contents have changed since the
|
|
||||||
* last paint.
|
|
||||||
*/
|
|
||||||
bool IsDirty() {
|
|
||||||
// We can only tell if we are dirty if we're part of the
|
|
||||||
// widget's retained layer tree.
|
|
||||||
if (!mManager || !mManager->IsWidgetLayerManager()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return mCanvasRenderer->IsDirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
const nsIntRect& GetBounds() const { return mBounds; }
|
|
||||||
|
|
||||||
RefPtr<CanvasRenderer> CreateOrGetCanvasRenderer();
|
|
||||||
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* CONSTRUCTION PHASE ONLY
|
|
||||||
* Set the filter used to resample this image (if necessary).
|
|
||||||
*/
|
|
||||||
void SetSamplingFilter(gfx::SamplingFilter aSamplingFilter) {
|
|
||||||
if (mSamplingFilter != aSamplingFilter) {
|
|
||||||
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) Filter", this));
|
|
||||||
mSamplingFilter = aSamplingFilter;
|
|
||||||
Mutated();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
gfx::SamplingFilter GetSamplingFilter() const { return mSamplingFilter; }
|
|
||||||
|
|
||||||
MOZ_LAYER_DECL_NAME("CanvasLayer", TYPE_CANVAS)
|
|
||||||
|
|
||||||
void ComputeEffectiveTransforms(
|
|
||||||
const gfx::Matrix4x4& aTransformToSurface) override {
|
|
||||||
// Snap our local transform first, and snap the inherited transform as well.
|
|
||||||
// This makes our snapping equivalent to what would happen if our content
|
|
||||||
// was drawn into a PaintedLayer (gfxContext would snap using the local
|
|
||||||
// transform, then we'd snap again when compositing the PaintedLayer).
|
|
||||||
mEffectiveTransform =
|
|
||||||
SnapTransform(GetLocalTransform(),
|
|
||||||
gfxRect(0, 0, mBounds.Width(), mBounds.Height()),
|
|
||||||
nullptr) *
|
|
||||||
SnapTransformTranslation(aTransformToSurface, nullptr);
|
|
||||||
ComputeEffectiveTransformForMaskLayers(aTransformToSurface);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
CanvasLayer(LayerManager* aManager, void* aImplData);
|
|
||||||
virtual ~CanvasLayer();
|
|
||||||
|
|
||||||
void PrintInfo(std::stringstream& aStream, const char* aPrefix) override;
|
|
||||||
|
|
||||||
virtual RefPtr<CanvasRenderer> CreateCanvasRendererInternal() = 0;
|
|
||||||
|
|
||||||
RefPtr<CanvasRenderer> mCanvasRenderer;
|
|
||||||
gfx::SamplingFilter mSamplingFilter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 0, 0, canvaswidth, canvasheight
|
|
||||||
*/
|
|
||||||
gfx::IntRect mBounds;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ContainerLayer that refers to a "foreign" layer tree, through an
|
* ContainerLayer that refers to a "foreign" layer tree, through an
|
||||||
* ID. Usage of RefLayer looks like
|
* ID. Usage of RefLayer looks like
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "ScrollThumbUtils.h"
|
#include "ScrollThumbUtils.h"
|
||||||
#include "AsyncPanZoomController.h"
|
#include "AsyncPanZoomController.h"
|
||||||
#include "FrameMetrics.h"
|
#include "FrameMetrics.h"
|
||||||
|
#include "gfxPlatform.h"
|
||||||
#include "mozilla/gfx/Matrix.h"
|
#include "mozilla/gfx/Matrix.h"
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
#include "apz/src/AsyncPanZoomController.h"
|
#include "apz/src/AsyncPanZoomController.h"
|
||||||
#include "apz/src/HitTestingTreeNode.h"
|
#include "apz/src/HitTestingTreeNode.h"
|
||||||
#include "base/task.h"
|
#include "base/task.h"
|
||||||
|
#include "gfxPlatform.h"
|
||||||
#include "Layers.h"
|
#include "Layers.h"
|
||||||
#include "TestLayers.h"
|
#include "TestLayers.h"
|
||||||
#include "UnitTransforms.h"
|
#include "UnitTransforms.h"
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
||||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
||||||
/* 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 GFX_CLIENTCANVASRENDERER_H
|
|
||||||
#define GFX_CLIENTCANVASRENDERER_H
|
|
||||||
|
|
||||||
#include "ShareableCanvasRenderer.h"
|
|
||||||
|
|
||||||
namespace mozilla {
|
|
||||||
namespace layers {
|
|
||||||
|
|
||||||
class ClientCanvasLayer;
|
|
||||||
|
|
||||||
class ClientCanvasRenderer final : public ShareableCanvasRenderer {
|
|
||||||
public:
|
|
||||||
explicit ClientCanvasRenderer(ClientCanvasLayer* aLayer) : mLayer(aLayer) {}
|
|
||||||
|
|
||||||
ClientCanvasRenderer* AsClientCanvasRenderer() override { return this; }
|
|
||||||
|
|
||||||
CompositableForwarder* GetForwarder() override;
|
|
||||||
|
|
||||||
bool CreateCompositable() override;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
ClientCanvasLayer* mLayer;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace layers
|
|
||||||
} // namespace mozilla
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -346,16 +346,6 @@ TextureFactoryIdentifier CompositorD3D11::GetTextureFactoryIdentifier() {
|
|||||||
return ident;
|
return ident;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CompositorD3D11::CanUseCanvasLayerForSize(const gfx::IntSize& aSize) {
|
|
||||||
int32_t maxTextureSize = GetMaxTextureSize();
|
|
||||||
|
|
||||||
if (aSize.width > maxTextureSize || aSize.height > maxTextureSize) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t CompositorD3D11::GetMaxTextureSize() const {
|
int32_t CompositorD3D11::GetMaxTextureSize() const {
|
||||||
return GetMaxTextureSizeForFeatureLevel(mFeatureLevel);
|
return GetMaxTextureSizeForFeatureLevel(mFeatureLevel);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ class CompositorD3D11 : public Compositor {
|
|||||||
already_AddRefed<DataTextureSource> CreateDataTextureSource(
|
already_AddRefed<DataTextureSource> CreateDataTextureSource(
|
||||||
TextureFlags aFlags = TextureFlags::NO_FLAGS) override;
|
TextureFlags aFlags = TextureFlags::NO_FLAGS) override;
|
||||||
|
|
||||||
bool CanUseCanvasLayerForSize(const gfx::IntSize& aSize) override;
|
|
||||||
int32_t GetMaxTextureSize() const final;
|
int32_t GetMaxTextureSize() const final;
|
||||||
|
|
||||||
void MakeCurrent(MakeCurrentFlags aFlags = 0) override {}
|
void MakeCurrent(MakeCurrentFlags aFlags = 0) override {}
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ include protocol PTexture;
|
|||||||
|
|
||||||
include "gfxipc/ShadowLayerUtils.h";
|
include "gfxipc/ShadowLayerUtils.h";
|
||||||
include "mozilla/GfxMessageUtils.h";
|
include "mozilla/GfxMessageUtils.h";
|
||||||
include "ImageLayers.h";
|
|
||||||
|
|
||||||
using mozilla::gfx::Glyph from "mozilla/gfx/2D.h";
|
using mozilla::gfx::Glyph from "mozilla/gfx/2D.h";
|
||||||
using mozilla::gfx::SamplingFilter from "mozilla/gfx/2D.h";
|
using mozilla::gfx::SamplingFilter from "mozilla/gfx/2D.h";
|
||||||
@@ -82,9 +81,7 @@ struct TargetConfig {
|
|||||||
// Create a shadow layer for |layer|
|
// Create a shadow layer for |layer|
|
||||||
struct OpCreatePaintedLayer { LayerHandle layer; };
|
struct OpCreatePaintedLayer { LayerHandle layer; };
|
||||||
struct OpCreateContainerLayer { LayerHandle layer; };
|
struct OpCreateContainerLayer { LayerHandle layer; };
|
||||||
struct OpCreateImageLayer { LayerHandle layer; };
|
|
||||||
struct OpCreateColorLayer { LayerHandle layer; };
|
struct OpCreateColorLayer { LayerHandle layer; };
|
||||||
struct OpCreateCanvasLayer { LayerHandle layer; };
|
|
||||||
struct OpCreateRefLayer { LayerHandle layer; };
|
struct OpCreateRefLayer { LayerHandle layer; };
|
||||||
|
|
||||||
struct OpAttachCompositable {
|
struct OpAttachCompositable {
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ EXPORTS += [
|
|||||||
"GLImages.h",
|
"GLImages.h",
|
||||||
"GPUVideoImage.h",
|
"GPUVideoImage.h",
|
||||||
"ImageContainer.h",
|
"ImageContainer.h",
|
||||||
"ImageLayers.h",
|
|
||||||
"ImageTypes.h",
|
"ImageTypes.h",
|
||||||
"IMFYCbCrImage.h",
|
"IMFYCbCrImage.h",
|
||||||
"Layers.h",
|
"Layers.h",
|
||||||
@@ -366,7 +365,6 @@ UNIFIED_SOURCES += [
|
|||||||
"FrameMetrics.cpp",
|
"FrameMetrics.cpp",
|
||||||
"GLImages.cpp",
|
"GLImages.cpp",
|
||||||
"ImageDataSerializer.cpp",
|
"ImageDataSerializer.cpp",
|
||||||
"ImageLayers.cpp",
|
|
||||||
"ipc/APZChild.cpp",
|
"ipc/APZChild.cpp",
|
||||||
"ipc/APZCTreeManagerChild.cpp",
|
"ipc/APZCTreeManagerChild.cpp",
|
||||||
"ipc/APZCTreeManagerParent.cpp",
|
"ipc/APZCTreeManagerParent.cpp",
|
||||||
|
|||||||
@@ -200,12 +200,6 @@ class CompositorOGL final : public Compositor {
|
|||||||
|
|
||||||
bool SupportsPartialTextureUpdate() override;
|
bool SupportsPartialTextureUpdate() override;
|
||||||
|
|
||||||
bool CanUseCanvasLayerForSize(const gfx::IntSize& aSize) override {
|
|
||||||
if (!mGLContext) return false;
|
|
||||||
int32_t maxSize = GetMaxTextureSize();
|
|
||||||
return aSize <= gfx::IntSize(maxSize, maxSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t GetMaxTextureSize() const override;
|
int32_t GetMaxTextureSize() const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ namespace mozilla {
|
|||||||
|
|
||||||
namespace layers {
|
namespace layers {
|
||||||
|
|
||||||
class CanvasLayer;
|
|
||||||
class ImageClient;
|
class ImageClient;
|
||||||
class ImageContainer;
|
class ImageContainer;
|
||||||
class WebRenderBridgeChild;
|
class WebRenderBridgeChild;
|
||||||
|
|||||||
@@ -103,9 +103,7 @@ class WebRenderLayerManager final : public LayerManager {
|
|||||||
already_AddRefed<ContainerLayer> CreateContainerLayer() override {
|
already_AddRefed<ContainerLayer> CreateContainerLayer() override {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
already_AddRefed<ImageLayer> CreateImageLayer() override { return nullptr; }
|
|
||||||
already_AddRefed<ColorLayer> CreateColorLayer() override { return nullptr; }
|
already_AddRefed<ColorLayer> CreateColorLayer() override { return nullptr; }
|
||||||
already_AddRefed<CanvasLayer> CreateCanvasLayer() override { return nullptr; }
|
|
||||||
|
|
||||||
bool NeedsWidgetInvalidation() override { return false; }
|
bool NeedsWidgetInvalidation() override { return false; }
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ class SourceSurface;
|
|||||||
namespace layers {
|
namespace layers {
|
||||||
|
|
||||||
class BasicLayerManager;
|
class BasicLayerManager;
|
||||||
class CanvasLayer;
|
|
||||||
class ImageClient;
|
class ImageClient;
|
||||||
class ImageContainer;
|
class ImageContainer;
|
||||||
class WebRenderBridgeChild;
|
class WebRenderBridgeChild;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "TestLayers.h"
|
#include "TestLayers.h"
|
||||||
|
#include "gfxPlatform.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "gmock/gmock.h"
|
#include "gmock/gmock.h"
|
||||||
#include "LayerUserData.h"
|
#include "LayerUserData.h"
|
||||||
@@ -55,9 +56,6 @@ class TestLayerManager : public LayerManager {
|
|||||||
virtual void GetBackendName(nsAString& aName) {}
|
virtual void GetBackendName(nsAString& aName) {}
|
||||||
virtual LayersBackend GetBackendType() { return LayersBackend::LAYERS_BASIC; }
|
virtual LayersBackend GetBackendType() { return LayersBackend::LAYERS_BASIC; }
|
||||||
virtual bool BeginTransaction(const nsCString& = nsCString()) { return true; }
|
virtual bool BeginTransaction(const nsCString& = nsCString()) { return true; }
|
||||||
virtual already_AddRefed<ImageLayer> CreateImageLayer() {
|
|
||||||
MOZ_CRASH("Not implemented.");
|
|
||||||
}
|
|
||||||
virtual already_AddRefed<PaintedLayer> CreatePaintedLayer() {
|
virtual already_AddRefed<PaintedLayer> CreatePaintedLayer() {
|
||||||
RefPtr<PaintedLayer> layer = new TestPaintedLayer(this);
|
RefPtr<PaintedLayer> layer = new TestPaintedLayer(this);
|
||||||
return layer.forget();
|
return layer.forget();
|
||||||
@@ -70,9 +68,6 @@ class TestLayerManager : public LayerManager {
|
|||||||
const nsCString& = nsCString()) {
|
const nsCString& = nsCString()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
virtual already_AddRefed<CanvasLayer> CreateCanvasLayer() {
|
|
||||||
MOZ_CRASH("Not implemented.");
|
|
||||||
}
|
|
||||||
virtual void EndTransaction(DrawPaintedLayerCallback aCallback,
|
virtual void EndTransaction(DrawPaintedLayerCallback aCallback,
|
||||||
void* aCallbackData,
|
void* aCallbackData,
|
||||||
EndTransactionFlags aFlags = END_DEFAULT) {}
|
EndTransactionFlags aFlags = END_DEFAULT) {}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#include "mozilla/RefPtr.h"
|
#include "mozilla/RefPtr.h"
|
||||||
#include "gfx2DGlue.h"
|
#include "gfx2DGlue.h"
|
||||||
#include "gfxImageSurface.h"
|
#include "gfxImageSurface.h"
|
||||||
|
#include "gfxPlatform.h"
|
||||||
#include "gfxTypes.h"
|
#include "gfxTypes.h"
|
||||||
#include "ImageContainer.h"
|
#include "ImageContainer.h"
|
||||||
#include "mozilla/layers/ImageDataSerializer.h"
|
#include "mozilla/layers/ImageDataSerializer.h"
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
#include "nsDisplayList.h"
|
#include "nsDisplayList.h"
|
||||||
#include "nsLayoutUtils.h"
|
#include "nsLayoutUtils.h"
|
||||||
#include "nsStyleUtil.h"
|
#include "nsStyleUtil.h"
|
||||||
#include "ImageLayers.h"
|
|
||||||
#include "Layers.h"
|
#include "Layers.h"
|
||||||
#include "ActiveLayerTracker.h"
|
#include "ActiveLayerTracker.h"
|
||||||
|
|
||||||
|
|||||||
@@ -80,7 +80,6 @@
|
|||||||
#include "nsNameSpaceManager.h"
|
#include "nsNameSpaceManager.h"
|
||||||
#include "nsIPercentBSizeObserver.h"
|
#include "nsIPercentBSizeObserver.h"
|
||||||
#include "nsStyleStructInlines.h"
|
#include "nsStyleStructInlines.h"
|
||||||
#include "ImageLayers.h"
|
|
||||||
|
|
||||||
#include "nsBidiPresUtils.h"
|
#include "nsBidiPresUtils.h"
|
||||||
#include "RubyUtils.h"
|
#include "RubyUtils.h"
|
||||||
|
|||||||
@@ -78,7 +78,6 @@
|
|||||||
#include "nsBidiPresUtils.h"
|
#include "nsBidiPresUtils.h"
|
||||||
|
|
||||||
#include "gfxRect.h"
|
#include "gfxRect.h"
|
||||||
#include "ImageLayers.h"
|
|
||||||
#include "ImageRegion.h"
|
#include "ImageRegion.h"
|
||||||
#include "ImageContainer.h"
|
#include "ImageContainer.h"
|
||||||
#include "mozilla/ServoStyleSet.h"
|
#include "mozilla/ServoStyleSet.h"
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
#include "nsIContentInlines.h"
|
#include "nsIContentInlines.h"
|
||||||
#include "nsIScriptError.h"
|
#include "nsIScriptError.h"
|
||||||
#include "nsContentUtils.h"
|
#include "nsContentUtils.h"
|
||||||
#include "ImageLayers.h"
|
|
||||||
|
|
||||||
#ifdef ACCESSIBILITY
|
#ifdef ACCESSIBILITY
|
||||||
# include "nsAccessibilityService.h"
|
# include "nsAccessibilityService.h"
|
||||||
|
|||||||
@@ -28,7 +28,6 @@
|
|||||||
#include "nsContentUtils.h"
|
#include "nsContentUtils.h"
|
||||||
#include "nsLayoutUtils.h"
|
#include "nsLayoutUtils.h"
|
||||||
#include "ImageContainer.h"
|
#include "ImageContainer.h"
|
||||||
#include "ImageLayers.h"
|
|
||||||
#include "nsStyleUtil.h"
|
#include "nsStyleUtil.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
|||||||
@@ -53,11 +53,11 @@
|
|||||||
#include "mozilla/MathAlgorithms.h"
|
#include "mozilla/MathAlgorithms.h"
|
||||||
|
|
||||||
#include "imgIContainer.h"
|
#include "imgIContainer.h"
|
||||||
|
#include "Layers.h"
|
||||||
#include "nsBoxFrame.h"
|
#include "nsBoxFrame.h"
|
||||||
#include "nsImageFrame.h"
|
#include "nsImageFrame.h"
|
||||||
#include "nsSubDocumentFrame.h"
|
#include "nsSubDocumentFrame.h"
|
||||||
#include "nsViewManager.h"
|
#include "nsViewManager.h"
|
||||||
#include "ImageLayers.h"
|
|
||||||
#include "ImageContainer.h"
|
#include "ImageContainer.h"
|
||||||
#include "nsCanvasFrame.h"
|
#include "nsCanvasFrame.h"
|
||||||
#include "nsSubDocumentFrame.h"
|
#include "nsSubDocumentFrame.h"
|
||||||
|
|||||||
@@ -38,7 +38,6 @@
|
|||||||
#include "nsIURI.h"
|
#include "nsIURI.h"
|
||||||
#include "nsThreadUtils.h"
|
#include "nsThreadUtils.h"
|
||||||
#include "nsDisplayList.h"
|
#include "nsDisplayList.h"
|
||||||
#include "ImageLayers.h"
|
|
||||||
#include "ImageRegion.h"
|
#include "ImageRegion.h"
|
||||||
#include "ImageContainer.h"
|
#include "ImageContainer.h"
|
||||||
#include "nsIContent.h"
|
#include "nsIContent.h"
|
||||||
|
|||||||
Reference in New Issue
Block a user