зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 67142a370d4a (bug 1598998) for causing failures in ImageBitmapRenderingContext.cpp
CLOSED TREE --HG-- extra : histedit_source : 1e4895b3c8773f7881b99f1ab0fca9c6b64b7644
This commit is contained in:
Родитель
de7fbf7ab8
Коммит
c8ca91e7db
|
@ -258,23 +258,6 @@ NS_IMETHODIMP
|
|||
ImageBitmapRenderingContext::Redraw(const gfxRect& aDirty) {
|
||||
mIsCapturedFrameInvalid = true;
|
||||
|
||||
if (mOffscreenCanvas) {
|
||||
RefPtr<layers::ImageContainer> imageContainer =
|
||||
mOffscreenCanvas->GetImageContainer();
|
||||
MOZ_ASSERT(imageContainer);
|
||||
if (imageContainer) {
|
||||
RefPtr<layers::Image> image = ClipToIntrinsicSize();
|
||||
if (image) {
|
||||
AutoTArray<ImageContainer::NonOwningImage, 1> imageList;
|
||||
imageList.AppendElement(ImageContainer::NonOwningImage(image));
|
||||
imageContainer->SetCurrentImages(imageList);
|
||||
} else {
|
||||
imageContainer->ClearAllImages();
|
||||
}
|
||||
}
|
||||
mOffscreenCanvas->CommitFrameToCompositor();
|
||||
}
|
||||
|
||||
if (!mCanvasElement) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -116,7 +116,6 @@ already_AddRefed<nsISupports> OffscreenCanvas::GetContext(
|
|||
}
|
||||
|
||||
if (mCanvasRenderer) {
|
||||
mCanvasRenderer->SetContextType(contextType);
|
||||
if (contextType == CanvasContextType::WebGL1 ||
|
||||
contextType == CanvasContextType::WebGL2) {
|
||||
WebGLContext* webGL = static_cast<WebGLContext*>(mCurrentContext.get());
|
||||
|
@ -149,13 +148,6 @@ already_AddRefed<nsISupports> OffscreenCanvas::GetContext(
|
|||
return result.forget();
|
||||
}
|
||||
|
||||
ImageContainer* OffscreenCanvas::GetImageContainer() {
|
||||
if (!mCanvasRenderer) {
|
||||
return nullptr;
|
||||
}
|
||||
return mCanvasRenderer->GetImageContainer();
|
||||
}
|
||||
|
||||
already_AddRefed<nsICanvasRenderingContextInternal>
|
||||
OffscreenCanvas::CreateContext(CanvasContextType aContextType) {
|
||||
RefPtr<nsICanvasRenderingContextInternal> ret =
|
||||
|
@ -183,9 +175,7 @@ void OffscreenCanvas::CommitFrameToCompositor() {
|
|||
mAttrDirty = false;
|
||||
}
|
||||
|
||||
CanvasContextType contentType = mCanvasRenderer->GetContextType();
|
||||
if (mCurrentContext && (contentType == CanvasContextType::WebGL1 ||
|
||||
contentType == CanvasContextType::WebGL2)) {
|
||||
if (mCurrentContext) {
|
||||
static_cast<WebGLContext*>(mCurrentContext.get())->PresentScreenBuffer();
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ class ErrorResult;
|
|||
namespace layers {
|
||||
class AsyncCanvasRenderer;
|
||||
class CanvasClient;
|
||||
class ImageContainer;
|
||||
} // namespace layers
|
||||
|
||||
namespace dom {
|
||||
|
@ -147,8 +146,6 @@ class OffscreenCanvas final : public DOMEventTargetHelper,
|
|||
return mCompositorBackendType;
|
||||
}
|
||||
|
||||
layers::ImageContainer* GetImageContainer();
|
||||
|
||||
private:
|
||||
~OffscreenCanvas();
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include "mozilla/dom/HTMLCanvasElement.h"
|
||||
|
||||
#include "ImageEncoder.h"
|
||||
#include "ImageLayers.h"
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "Layers.h"
|
||||
|
@ -1076,13 +1075,6 @@ bool HTMLCanvasElement::GetOpaqueAttr() {
|
|||
return HasAttr(kNameSpaceID_None, nsGkAtoms::moz_opaque);
|
||||
}
|
||||
|
||||
CanvasContextType HTMLCanvasElement::GetCurrentContextType() {
|
||||
if (mAsyncCanvasRenderer) {
|
||||
return mAsyncCanvasRenderer->GetContextType();
|
||||
}
|
||||
return mCurrentContextType;
|
||||
}
|
||||
|
||||
already_AddRefed<Layer> HTMLCanvasElement::GetCanvasLayer(
|
||||
nsDisplayListBuilder* aBuilder, Layer* aOldLayer, LayerManager* aManager) {
|
||||
// The address of sOffscreenCanvasLayerUserDataDummy is used as the user
|
||||
|
@ -1090,67 +1082,35 @@ already_AddRefed<Layer> HTMLCanvasElement::GetCanvasLayer(
|
|||
// We don't much care about what value in it, so just assign a dummy
|
||||
// value for it.
|
||||
static uint8_t sOffscreenCanvasLayerUserDataDummy = 0;
|
||||
static uint8_t sOffscreenImageLayerUserDataDummy = 0;
|
||||
|
||||
if (mCurrentContext) {
|
||||
return mCurrentContext->GetCanvasLayer(aBuilder, aOldLayer, aManager);
|
||||
}
|
||||
|
||||
if (mOffscreenCanvas) {
|
||||
CanvasContextType contentType = mAsyncCanvasRenderer->GetContextType();
|
||||
if (contentType == CanvasContextType::NoContext) {
|
||||
// context is not created yet.
|
||||
if (!mResetLayer && aOldLayer &&
|
||||
aOldLayer->HasUserData(&sOffscreenCanvasLayerUserDataDummy)) {
|
||||
RefPtr<Layer> ret = aOldLayer;
|
||||
return ret.forget();
|
||||
}
|
||||
|
||||
RefPtr<CanvasLayer> layer = aManager->CreateCanvasLayer();
|
||||
if (!layer) {
|
||||
NS_WARNING("CreateCanvasLayer failed!");
|
||||
return nullptr;
|
||||
}
|
||||
if (contentType != CanvasContextType::ImageBitmap) {
|
||||
if (!mResetLayer && aOldLayer &&
|
||||
aOldLayer->HasUserData(&sOffscreenCanvasLayerUserDataDummy)) {
|
||||
RefPtr<Layer> ret = aOldLayer;
|
||||
return ret.forget();
|
||||
}
|
||||
|
||||
RefPtr<CanvasLayer> layer = aManager->CreateCanvasLayer();
|
||||
if (!layer) {
|
||||
NS_WARNING("CreateCanvasLayer failed!");
|
||||
return nullptr;
|
||||
}
|
||||
LayerUserData* userData = nullptr;
|
||||
layer->SetUserData(&sOffscreenCanvasLayerUserDataDummy, userData);
|
||||
|
||||
LayerUserData* userData = nullptr;
|
||||
layer->SetUserData(&sOffscreenCanvasLayerUserDataDummy, userData);
|
||||
CanvasRenderer* canvasRenderer = layer->CreateOrGetCanvasRenderer();
|
||||
|
||||
CanvasRenderer* canvasRenderer = layer->CreateOrGetCanvasRenderer();
|
||||
|
||||
if (!InitializeCanvasRenderer(aBuilder, canvasRenderer)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
layer->Updated();
|
||||
mResetLayer = false;
|
||||
return layer.forget();
|
||||
if (!InitializeCanvasRenderer(aBuilder, canvasRenderer)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (contentType == CanvasContextType::ImageBitmap) {
|
||||
if (!mResetLayer && aOldLayer &&
|
||||
aOldLayer->HasUserData(&sOffscreenImageLayerUserDataDummy)) {
|
||||
RefPtr<Layer> ret = aOldLayer;
|
||||
return ret.forget();
|
||||
}
|
||||
|
||||
RefPtr<ImageLayer> layer = aManager->CreateImageLayer();
|
||||
if (!layer) {
|
||||
NS_WARNING("CreateImageLayer failed!");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
LayerUserData* userData = nullptr;
|
||||
layer->SetUserData(&sOffscreenImageLayerUserDataDummy, userData);
|
||||
|
||||
RefPtr<ImageContainer> imageContainer =
|
||||
mAsyncCanvasRenderer->GetImageContainer();
|
||||
MOZ_ASSERT(imageContainer);
|
||||
layer->SetContainer(imageContainer);
|
||||
mResetLayer = false;
|
||||
return layer.forget();
|
||||
}
|
||||
layer->Updated();
|
||||
return layer.forget();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
@ -1162,37 +1122,22 @@ bool HTMLCanvasElement::UpdateWebRenderCanvasData(
|
|||
return mCurrentContext->UpdateWebRenderCanvasData(aBuilder, aCanvasData);
|
||||
}
|
||||
if (mOffscreenCanvas) {
|
||||
CanvasContextType contentType = mAsyncCanvasRenderer->GetContextType();
|
||||
if (contentType == CanvasContextType::NoContext) {
|
||||
// context is not created yet.
|
||||
CanvasRenderer* renderer = aCanvasData->GetCanvasRenderer();
|
||||
|
||||
if (!mResetLayer && renderer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
renderer = aCanvasData->CreateCanvasRenderer();
|
||||
if (!InitializeCanvasRenderer(aBuilder, renderer)) {
|
||||
// Clear CanvasRenderer of WebRenderCanvasData
|
||||
aCanvasData->ClearCanvasRenderer();
|
||||
return false;
|
||||
}
|
||||
if (contentType != CanvasContextType::ImageBitmap) {
|
||||
CanvasRenderer* renderer = aCanvasData->GetCanvasRenderer();
|
||||
|
||||
if (!mResetLayer && renderer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
renderer = aCanvasData->CreateCanvasRenderer();
|
||||
if (!InitializeCanvasRenderer(aBuilder, renderer)) {
|
||||
// Clear CanvasRenderer of WebRenderCanvasData
|
||||
aCanvasData->ClearCanvasRenderer();
|
||||
return false;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(renderer);
|
||||
mResetLayer = false;
|
||||
return true;
|
||||
}
|
||||
if (contentType == CanvasContextType::ImageBitmap) {
|
||||
RefPtr<ImageContainer> imageContainer =
|
||||
mAsyncCanvasRenderer->GetImageContainer();
|
||||
MOZ_ASSERT(imageContainer);
|
||||
aCanvasData->SetImageContainer(imageContainer);
|
||||
mResetLayer = false;
|
||||
return true;
|
||||
}
|
||||
MOZ_ASSERT(renderer);
|
||||
mResetLayer = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Clear CanvasRenderer of WebRenderCanvasData
|
||||
|
|
|
@ -401,7 +401,7 @@ class HTMLCanvasElement final : public nsGenericHTMLElement,
|
|||
|
||||
HTMLCanvasElement* GetOriginalCanvas();
|
||||
|
||||
CanvasContextType GetCurrentContextType();
|
||||
CanvasContextType GetCurrentContextType() { return mCurrentContextType; }
|
||||
|
||||
private:
|
||||
/**
|
||||
|
|
|
@ -30,8 +30,7 @@ AsyncCanvasRenderer::AsyncCanvasRenderer()
|
|||
mWidth(0),
|
||||
mHeight(0),
|
||||
mCanvasClient(nullptr),
|
||||
mMutex("AsyncCanvasRenderer::mMutex"),
|
||||
mContextType(dom::CanvasContextType::NoContext) {
|
||||
mMutex("AsyncCanvasRenderer::mMutex") {
|
||||
MOZ_COUNT_CTOR(AsyncCanvasRenderer);
|
||||
}
|
||||
|
||||
|
@ -115,26 +114,6 @@ AsyncCanvasRenderer::GetActiveEventTarget() {
|
|||
return result.forget();
|
||||
}
|
||||
|
||||
ImageContainer* AsyncCanvasRenderer::GetImageContainer() {
|
||||
MOZ_ASSERT(mContextType == dom::CanvasContextType::ImageBitmap);
|
||||
MutexAutoLock lock(mMutex);
|
||||
if (!mImageContainer) {
|
||||
mImageContainer =
|
||||
LayerManager::CreateImageContainer(ImageContainer::ASYNCHRONOUS);
|
||||
}
|
||||
return mImageContainer;
|
||||
}
|
||||
|
||||
dom::CanvasContextType AsyncCanvasRenderer::GetContextType() {
|
||||
MutexAutoLock lock(mMutex);
|
||||
return mContextType;
|
||||
}
|
||||
|
||||
void AsyncCanvasRenderer::SetContextType(dom::CanvasContextType aContextType) {
|
||||
MutexAutoLock lock(mMutex);
|
||||
mContextType = aContextType;
|
||||
}
|
||||
|
||||
void AsyncCanvasRenderer::CopyFromTextureClient(TextureClient* aTextureClient) {
|
||||
MutexAutoLock lock(mMutex);
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#define MOZILLA_LAYERS_ASYNCCANVASRENDERER_H_
|
||||
|
||||
#include "LayersTypes.h"
|
||||
#include "mozilla/dom/CanvasRenderingContextHelper.h"
|
||||
#include "mozilla/gfx/Point.h" // for IntSize
|
||||
#include "mozilla/Mutex.h"
|
||||
#include "nsCOMPtr.h" // for nsCOMPtr
|
||||
|
@ -35,7 +34,6 @@ namespace layers {
|
|||
|
||||
class CanvasClient;
|
||||
class TextureClient;
|
||||
class ImageContainer;
|
||||
|
||||
/**
|
||||
* Since HTMLCanvasElement and OffscreenCanvas are not thread-safe, we create
|
||||
|
@ -104,11 +102,6 @@ class AsyncCanvasRenderer final {
|
|||
|
||||
already_AddRefed<nsISerialEventTarget> GetActiveEventTarget();
|
||||
|
||||
ImageContainer* GetImageContainer();
|
||||
|
||||
dom::CanvasContextType GetContextType();
|
||||
void SetContextType(dom::CanvasContextType aContextType);
|
||||
|
||||
// The lifetime is controllered by HTMLCanvasElement.
|
||||
// Only accessed in main thread.
|
||||
dom::HTMLCanvasElement* mHTMLCanvasElement;
|
||||
|
@ -151,12 +144,6 @@ class AsyncCanvasRenderer final {
|
|||
|
||||
// Can be accessed in any thread, need protect by mutex.
|
||||
nsCOMPtr<nsISerialEventTarget> mActiveEventTarget;
|
||||
|
||||
// Can be accessed in any thread, need protect by mutex.
|
||||
RefPtr<ImageContainer> mImageContainer;
|
||||
|
||||
// Can be accessed in any thread, need protect by mutex.
|
||||
dom::CanvasContextType mContextType;
|
||||
};
|
||||
|
||||
} // namespace layers
|
||||
|
|
|
@ -372,10 +372,6 @@ WebRenderCanvasRendererAsync* WebRenderCanvasData::CreateCanvasRenderer() {
|
|||
return mCanvasRenderer.get();
|
||||
}
|
||||
|
||||
void WebRenderCanvasData::SetImageContainer(ImageContainer* aImageContainer) {
|
||||
mContainer = aImageContainer;
|
||||
}
|
||||
|
||||
ImageContainer* WebRenderCanvasData::GetImageContainer() {
|
||||
if (!mContainer) {
|
||||
mContainer = LayerManager::CreateImageContainer();
|
||||
|
|
|
@ -246,7 +246,6 @@ class WebRenderCanvasData : public WebRenderUserData {
|
|||
WebRenderCanvasRendererAsync* GetCanvasRenderer();
|
||||
WebRenderCanvasRendererAsync* CreateCanvasRenderer();
|
||||
|
||||
void SetImageContainer(ImageContainer* aImageContainer);
|
||||
ImageContainer* GetImageContainer();
|
||||
void ClearImageContainer();
|
||||
|
||||
|
|
|
@ -443,8 +443,8 @@ already_AddRefed<Layer> nsHTMLCanvasFrame::BuildLayer(
|
|||
if (canvasSizeInPx.width <= 0 || canvasSizeInPx.height <= 0 || area.IsEmpty())
|
||||
return nullptr;
|
||||
|
||||
Layer* oldLayer =
|
||||
aManager->GetLayerBuilder()->GetLeafLayerFor(aBuilder, aItem);
|
||||
CanvasLayer* oldLayer = static_cast<CanvasLayer*>(
|
||||
aManager->GetLayerBuilder()->GetLeafLayerFor(aBuilder, aItem));
|
||||
RefPtr<Layer> layer = element->GetCanvasLayer(aBuilder, oldLayer, aManager);
|
||||
if (!layer) return nullptr;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче