зеркало из https://github.com/mozilla/gecko-dev.git
backing out 2796c7 (bug 539771); a=b
This commit is contained in:
Родитель
7506d2533d
Коммит
65806647ae
|
@ -50,7 +50,6 @@
|
|||
class nsHTMLCanvasElement;
|
||||
class gfxContext;
|
||||
class gfxASurface;
|
||||
class nsIPropertyBag;
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
@ -116,14 +115,6 @@ public:
|
|||
// Redraw the dirty rectangle of this canvas.
|
||||
NS_IMETHOD Redraw(const gfxRect &dirty) = 0;
|
||||
|
||||
// Passes a generic nsIPropertyBag options argument, along with the
|
||||
// previous one, if any. Optional.
|
||||
NS_IMETHOD SetContextOptions(nsIPropertyBag *aNewOptions) { return NS_OK; }
|
||||
|
||||
//
|
||||
// shmem support
|
||||
//
|
||||
|
||||
// If this context can be set to use Mozilla's Shmem segments as its backing
|
||||
// store, this will set it to that state. Note that if you have drawn
|
||||
// anything into this canvas before changing the shmem state, it will be
|
||||
|
|
|
@ -47,9 +47,6 @@
|
|||
#include "nsIXPConnect.h"
|
||||
#include "nsDOMError.h"
|
||||
|
||||
#include "nsIPropertyBag.h"
|
||||
#include "nsIVariant.h"
|
||||
|
||||
#include "gfxContext.h"
|
||||
#include "gfxPattern.h"
|
||||
#include "gfxUtils.h"
|
||||
|
@ -88,7 +85,6 @@ WebGLContext::WebGLContext()
|
|||
mGeneration = 0;
|
||||
mInvalidated = PR_FALSE;
|
||||
mResetLayer = PR_TRUE;
|
||||
mOptionsFrozen = PR_FALSE;
|
||||
|
||||
mActiveTexture = 0;
|
||||
mSynthesizedGLError = LOCAL_GL_NO_ERROR;
|
||||
|
@ -259,58 +255,6 @@ WebGLContext::SetCanvasElement(nsHTMLCanvasElement* aParentCanvas)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
static bool
|
||||
GetBoolFromPropertyBag(nsIPropertyBag *bag, const char *propName, bool *boolResult)
|
||||
{
|
||||
nsCOMPtr<nsIVariant> vv;
|
||||
PRBool bv;
|
||||
|
||||
nsresult rv = bag->GetProperty(NS_ConvertASCIItoUTF16(propName), getter_AddRefs(vv));
|
||||
if (NS_FAILED(rv) || !vv)
|
||||
return false;
|
||||
|
||||
rv = vv->GetAsBool(&bv);
|
||||
if (NS_FAILED(rv))
|
||||
return false;
|
||||
|
||||
*boolResult = bv ? true : false;
|
||||
return true;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
WebGLContext::SetContextOptions(nsIPropertyBag *aOptions)
|
||||
{
|
||||
if (!aOptions)
|
||||
return NS_OK;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
WebGLContextOptions newOpts;
|
||||
|
||||
GetBoolFromPropertyBag(aOptions, "stencil", &newOpts.stencil);
|
||||
GetBoolFromPropertyBag(aOptions, "depth", &newOpts.depth);
|
||||
GetBoolFromPropertyBag(aOptions, "alpha", &newOpts.alpha);
|
||||
GetBoolFromPropertyBag(aOptions, "premultipliedAlpha", &newOpts.premultipliedAlpha);
|
||||
|
||||
GetBoolFromPropertyBag(aOptions, "antialiasHint", &newOpts.antialiasHint);
|
||||
|
||||
LogMessage("aaHint: %d stencil: %d depth: %d alpha: %d premult: %d\n",
|
||||
newOpts.antialiasHint ? 1 : 0,
|
||||
newOpts.stencil ? 1 : 0,
|
||||
newOpts.depth ? 1 : 0,
|
||||
newOpts.alpha ? 1 : 0,
|
||||
newOpts.premultipliedAlpha ? 1 : 0);
|
||||
|
||||
if (mOptionsFrozen && newOpts != mOptions) {
|
||||
// Error if the options are already frozen, and the ones that were asked for
|
||||
// aren't the same as what they were originally.
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
mOptions = newOpts;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
WebGLContext::SetDimensions(PRInt32 width, PRInt32 height)
|
||||
{
|
||||
|
@ -345,26 +289,8 @@ WebGLContext::SetDimensions(PRInt32 width, PRInt32 height)
|
|||
DestroyResourcesAndContext();
|
||||
|
||||
gl::ContextFormat format(gl::ContextFormat::BasicRGBA32);
|
||||
if (mOptions.depth) {
|
||||
format.depth = 24;
|
||||
format.minDepth = 16;
|
||||
}
|
||||
|
||||
if (mOptions.stencil) {
|
||||
format.stencil = 8;
|
||||
format.minStencil = 8;
|
||||
}
|
||||
|
||||
if (!mOptions.alpha) {
|
||||
// Select 565; we won't/shouldn't hit this on the desktop,
|
||||
// but let mobile know we're ok with it.
|
||||
format.red = 5;
|
||||
format.green = 6;
|
||||
format.blue = 5;
|
||||
|
||||
format.alpha = 0;
|
||||
format.minAlpha = 0;
|
||||
}
|
||||
format.depth = 16;
|
||||
format.minDepth = 1;
|
||||
|
||||
nsCOMPtr<nsIPrefBranch> prefService = do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
NS_ENSURE_TRUE(prefService != nsnull, NS_ERROR_FAILURE);
|
||||
|
@ -448,7 +374,6 @@ WebGLContext::SetDimensions(PRInt32 width, PRInt32 height)
|
|||
mWidth = width;
|
||||
mHeight = height;
|
||||
mResetLayer = PR_TRUE;
|
||||
mOptionsFrozen = PR_TRUE;
|
||||
|
||||
// increment the generation number
|
||||
++mGeneration;
|
||||
|
@ -614,7 +539,7 @@ WebGLContext::GetCanvasLayer(CanvasLayer *aOldLayer,
|
|||
}
|
||||
|
||||
data.mSize = nsIntSize(mWidth, mHeight);
|
||||
data.mGLBufferIsPremultiplied = mOptions.premultipliedAlpha ? PR_TRUE : PR_FALSE;
|
||||
data.mGLBufferIsPremultiplied = PR_FALSE;
|
||||
|
||||
canvasLayer->Initialize(data);
|
||||
canvasLayer->SetIsOpaqueContent(gl->CreationFormat().alpha == 0 ? PR_TRUE : PR_FALSE);
|
||||
|
|
|
@ -67,7 +67,6 @@
|
|||
#define CONTEXT_LOST_WEBGL 0x9242
|
||||
|
||||
class nsIDocShell;
|
||||
class nsIPropertyBag;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -267,39 +266,6 @@ struct WebGLVertexAttribData {
|
|||
}
|
||||
};
|
||||
|
||||
struct WebGLContextOptions {
|
||||
// these are defaults
|
||||
WebGLContextOptions()
|
||||
: alpha(true), depth(true), stencil(false),
|
||||
premultipliedAlpha(false), antialiasHint(false)
|
||||
{ }
|
||||
|
||||
bool operator==(const WebGLContextOptions& other) const {
|
||||
return
|
||||
alpha == other.alpha &&
|
||||
depth == other.depth &&
|
||||
stencil == other.stencil &&
|
||||
premultipliedAlpha == other.premultipliedAlpha &&
|
||||
antialiasHint == other.antialiasHint;
|
||||
}
|
||||
|
||||
bool operator!=(const WebGLContextOptions& other) const {
|
||||
return
|
||||
alpha != other.alpha ||
|
||||
depth != other.depth ||
|
||||
stencil != other.stencil ||
|
||||
premultipliedAlpha != other.premultipliedAlpha ||
|
||||
antialiasHint != other.antialiasHint;
|
||||
}
|
||||
|
||||
bool alpha;
|
||||
bool depth;
|
||||
bool stencil;
|
||||
|
||||
bool premultipliedAlpha;
|
||||
bool antialiasHint;
|
||||
};
|
||||
|
||||
class WebGLContext :
|
||||
public nsICanvasRenderingContextWebGL,
|
||||
public nsICanvasRenderingContextInternal,
|
||||
|
@ -328,8 +294,6 @@ public:
|
|||
nsIInputStream **aStream);
|
||||
NS_IMETHOD GetThebesSurface(gfxASurface **surface);
|
||||
NS_IMETHOD SetIsOpaque(PRBool b) { return NS_OK; };
|
||||
NS_IMETHOD SetContextOptions(nsIPropertyBag *aOptions);
|
||||
|
||||
NS_IMETHOD SetIsIPC(PRBool b) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
NS_IMETHOD Redraw(const gfxRect&) { return NS_ERROR_NOT_IMPLEMENTED; }
|
||||
NS_IMETHOD Swap(mozilla::ipc::Shmem& aBack,
|
||||
|
@ -382,11 +346,8 @@ protected:
|
|||
PRInt32 mWidth, mHeight;
|
||||
CheckedUint32 mGeneration;
|
||||
|
||||
WebGLContextOptions mOptions;
|
||||
|
||||
PRPackedBool mInvalidated;
|
||||
PRPackedBool mResetLayer;
|
||||
PRPackedBool mOptionsFrozen;
|
||||
|
||||
WebGLuint mActiveTexture;
|
||||
WebGLenum mSynthesizedGLError;
|
||||
|
|
|
@ -167,7 +167,7 @@ public:
|
|||
protected:
|
||||
nsIntSize GetWidthHeight();
|
||||
|
||||
nsresult UpdateContext(nsIPropertyBag *aNewContextOptions = nsnull);
|
||||
nsresult UpdateContext();
|
||||
nsresult ToDataURLImpl(const nsAString& aMimeType,
|
||||
const nsAString& aEncoderOptions,
|
||||
nsAString& aDataURL);
|
||||
|
|
|
@ -148,7 +148,7 @@ nsHTMLCanvasElement::CopyInnerTo(nsGenericElement* aDest) const
|
|||
if (aDest->GetOwnerDoc()->IsStaticDocument()) {
|
||||
nsHTMLCanvasElement* dest = static_cast<nsHTMLCanvasElement*>(aDest);
|
||||
nsCOMPtr<nsISupports> cxt;
|
||||
dest->GetContext(NS_LITERAL_STRING("2d"), nsnull, getter_AddRefs(cxt));
|
||||
dest->GetContext(NS_LITERAL_STRING("2d"), getter_AddRefs(cxt));
|
||||
nsCOMPtr<nsIDOMCanvasRenderingContext2D> context2d = do_QueryInterface(cxt);
|
||||
if (context2d) {
|
||||
context2d->DrawImage(const_cast<nsHTMLCanvasElement*>(this),
|
||||
|
@ -226,27 +226,31 @@ nsHTMLCanvasElement::ToDataURLImpl(const nsAString& aMimeType,
|
|||
nsAString& aDataURL)
|
||||
{
|
||||
bool fallbackToPNG = false;
|
||||
nsresult rv;
|
||||
|
||||
|
||||
// We get an input stream from the context. If more than one context type
|
||||
// is supported in the future, this will have to be changed to do the right
|
||||
// thing. For now, just assume that the 2D context has all the goods.
|
||||
if (!mCurrentContext)
|
||||
return NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsICanvasRenderingContextInternal> context;
|
||||
nsresult rv = GetContext(NS_LITERAL_STRING("2d"), getter_AddRefs(context));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (!context) {
|
||||
// XXX bug 578349
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
// get image bytes
|
||||
nsCOMPtr<nsIInputStream> imgStream;
|
||||
NS_ConvertUTF16toUTF8 aMimeType8(aMimeType);
|
||||
rv = mCurrentContext->GetInputStream(nsPromiseFlatCString(aMimeType8).get(),
|
||||
nsPromiseFlatString(aEncoderOptions).get(),
|
||||
getter_AddRefs(imgStream));
|
||||
rv = context->GetInputStream(nsPromiseFlatCString(aMimeType8).get(),
|
||||
nsPromiseFlatString(aEncoderOptions).get(),
|
||||
getter_AddRefs(imgStream));
|
||||
if (NS_FAILED(rv)) {
|
||||
// Use image/png instead.
|
||||
// XXX ERRMSG we need to report an error to developers here! (bug 329026)
|
||||
fallbackToPNG = true;
|
||||
rv = mCurrentContext->GetInputStream("image/png",
|
||||
nsPromiseFlatString(aEncoderOptions).get(),
|
||||
getter_AddRefs(imgStream));
|
||||
rv = context->GetInputStream("image/png",
|
||||
nsPromiseFlatString(aEncoderOptions).get(),
|
||||
getter_AddRefs(imgStream));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
|
@ -349,7 +353,6 @@ nsHTMLCanvasElement::GetContextHelper(const nsAString& aContextId,
|
|||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLCanvasElement::GetContext(const nsAString& aContextId,
|
||||
nsIDOMHTMLCanvasContextOptions *aContextOptions,
|
||||
nsISupports **aContext)
|
||||
{
|
||||
nsresult rv;
|
||||
|
@ -376,8 +379,7 @@ nsHTMLCanvasElement::GetContext(const nsAString& aContextId,
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPropertyBag> contextProps = do_QueryInterface(aContextOptions);
|
||||
rv = UpdateContext(contextProps);
|
||||
rv = UpdateContext();
|
||||
if (NS_FAILED(rv)) {
|
||||
mCurrentContext = nsnull;
|
||||
return rv;
|
||||
|
@ -438,25 +440,14 @@ nsHTMLCanvasElement::MozGetIPCContext(const nsAString& aContextId,
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsHTMLCanvasElement::UpdateContext(nsIPropertyBag *aNewContextOptions)
|
||||
nsHTMLCanvasElement::UpdateContext()
|
||||
{
|
||||
if (!mCurrentContext)
|
||||
return NS_OK;
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
rv = mCurrentContext->SetIsOpaque(GetIsOpaque());
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = mCurrentContext->SetContextOptions(aNewContextOptions);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsIntSize sz = GetWidthHeight();
|
||||
rv = mCurrentContext->SetDimensions(sz.width, sz.height);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
if (mCurrentContext) {
|
||||
nsIntSize sz = GetWidthHeight();
|
||||
rv = mCurrentContext->SetIsOpaque(GetIsOpaque());
|
||||
rv = mCurrentContext->SetDimensions(sz.width, sz.height);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -37,12 +37,6 @@
|
|||
|
||||
#include "nsIDOMHTMLElement.idl"
|
||||
|
||||
[scriptable, uuid(2051f802-d377-441d-ace1-b0d9405e16f2)]
|
||||
interface nsIDOMHTMLCanvasContextOptions : nsISupports
|
||||
{
|
||||
// empty
|
||||
};
|
||||
|
||||
/**
|
||||
* The nsIDOMHTMLCanvasElement interface is the interface to a HTML
|
||||
* <canvas> element.
|
||||
|
@ -53,15 +47,15 @@ interface nsIDOMHTMLCanvasContextOptions : nsISupports
|
|||
* @status UNDER_DEVELOPMENT
|
||||
*/
|
||||
|
||||
[scriptable, uuid(53ad994a-3cd0-48fa-8ffb-7f3d8cd19c50)]
|
||||
[scriptable, uuid(56cee121-df62-49b6-b76d-71189441c98e)]
|
||||
interface nsIDOMHTMLCanvasElement : nsIDOMHTMLElement
|
||||
{
|
||||
attribute long width;
|
||||
attribute long height;
|
||||
attribute boolean mozOpaque;
|
||||
|
||||
nsISupports getContext(in DOMString contextId,
|
||||
[optional] in nsIDOMHTMLCanvasContextOptions contextOptions);
|
||||
nsISupports getContext(in DOMString contextId);
|
||||
|
||||
|
||||
// Valid calls are:
|
||||
// toDataURL(); -- defaults to image/png
|
||||
|
|
|
@ -526,7 +526,6 @@ CreatePBufferOffscreenContext(const gfxIntSize& aSize,
|
|||
A2(attrs, LOCAL_WGL_ALPHA_BITS_ARB, aFormat.alpha);
|
||||
|
||||
A2(attrs, LOCAL_WGL_DEPTH_BITS_ARB, aFormat.depth);
|
||||
A2(attrs, LOCAL_WGL_STENCIL_BITS_ARB, aFormat.stencil);
|
||||
|
||||
if (aFormat.alpha > 0) {
|
||||
A2(attrs, LOCAL_WGL_BIND_TO_TEXTURE_RGBA_ARB, LOCAL_GL_TRUE);
|
||||
|
|
|
@ -482,7 +482,6 @@ irregularFilenames = {
|
|||
'nsIDOMHTMLTableSectionElement': 'nsIDOMHTMLTableSectionElem',
|
||||
|
||||
# stowaways
|
||||
'nsIDOMHTMLCanvasContextOptions': 'nsIDOMHTMLCanvasElement',
|
||||
'nsIDOMTextMetrics': 'nsIDOMCanvasRenderingContext2D',
|
||||
'nsIDOMCanvasGradient': 'nsIDOMCanvasRenderingContext2D',
|
||||
'nsIDOMCanvasPattern': 'nsIDOMCanvasRenderingContext2D',
|
||||
|
|
Загрузка…
Ссылка в новой задаче