зеркало из https://github.com/mozilla/gecko-dev.git
b=516213; Freshen WebGL implementation and enable on trunk (part 2); r=mwsteele,roc
This commit is contained in:
Родитель
b109b87a48
Коммит
c62e96b0c0
11
configure.in
11
configure.in
|
@ -4465,7 +4465,7 @@ MOZ_BRANDING_DIRECTORY=
|
|||
MOZ_OFFICIAL_BRANDING=
|
||||
MOZ_DBGRINFO_MODULES=
|
||||
MOZ_ENABLE_CANVAS=1
|
||||
MOZ_ENABLE_CANVAS3D=
|
||||
MOZ_ENABLE_CANVAS3D=1
|
||||
MOZ_FEEDS=1
|
||||
MOZ_IMG_DECODERS_DEFAULT="png gif jpeg bmp icon"
|
||||
MOZ_IMG_ENCODERS_DEFAULT="png jpeg"
|
||||
|
@ -5768,10 +5768,11 @@ if test -n "$MOZ_ENABLE_CANVAS"; then
|
|||
fi
|
||||
AC_SUBST(MOZ_ENABLE_CANVAS)
|
||||
|
||||
MOZ_ARG_ENABLE_BOOL(canvas3d,
|
||||
[ --enable-canvas3d Enable canvas 3D context],
|
||||
MOZ_ENABLE_CANVAS3D=1,
|
||||
MOZ_ENABLE_CANVAS3D= )
|
||||
MOZ_ARG_DISABLE_BOOL(webgl,
|
||||
[ --disable-webgl Disable WebGL context (canvas 3d)],
|
||||
MOZ_ENABLE_CANVAS3D=,
|
||||
MOZ_ENABLE_CANVAS3D=1 )
|
||||
|
||||
if test -n "$MOZ_ENABLE_CANVAS3D"; then
|
||||
AC_DEFINE(MOZ_ENABLE_CANVAS3D)
|
||||
fi
|
||||
|
|
|
@ -38,8 +38,6 @@
|
|||
#ifndef WEBGLARRAY_H_
|
||||
#define WEBGLARRAY_H_
|
||||
|
||||
#include "nsICanvasRenderingContextWebGL.h"
|
||||
|
||||
nsresult NS_NewCanvasFloatArray(nsISupports **aNewObject);
|
||||
nsresult NS_NewCanvasByteArray(nsISupports **aNewObject);
|
||||
nsresult NS_NewCanvasUnsignedByteArray(nsISupports **aNewObject);
|
||||
|
|
|
@ -55,6 +55,11 @@ CPPSRCS = \
|
|||
|
||||
# Canvas 3D Pieces
|
||||
|
||||
# only allow on platforms/toolkits we know are good
|
||||
ifneq (,$(NS_OSSO)$(WINCE)$(filter-out windows cocoa gtk2,$(MOZ_WIDGET_TOOLKIT)))
|
||||
MOZ_ENABLE_CANVAS3D=
|
||||
endif
|
||||
|
||||
ifdef MOZ_ENABLE_CANVAS3D
|
||||
|
||||
CPPSRCS += \
|
||||
|
@ -90,6 +95,10 @@ CPPSRCS += nsGLPbufferCGL.cpp
|
|||
DEFINES += -DUSE_CGL
|
||||
endif
|
||||
|
||||
else
|
||||
|
||||
CPPSRCS += WebGLContextNotSupported.cpp
|
||||
|
||||
endif
|
||||
|
||||
# we don't want the shared lib, but we want to force the creation of a static lib.
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
* Vladimir Vukicevic <vladimir@pobox.com> (original author)
|
||||
* Mark Steele <mwsteele@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
|
|
|
@ -1,4 +1,42 @@
|
|||
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2009
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Vladimir Vukicevic <vladimir@pobox.com> (original author)
|
||||
* Mark Steele <mwsteele@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "WebGLContext.h"
|
||||
|
||||
#include "nsString.h"
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2009
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Vladimir Vukicevic <vladimir@pobox.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsICanvasRenderingContextWebGL.h"
|
||||
#include "WebGLArray.h"
|
||||
|
||||
#define DUMMY(func,rtype) nsresult func (rtype ** aResult) { return NS_ERROR_FAILURE; }
|
||||
|
||||
DUMMY(NS_NewCanvasRenderingContextWebGL, nsICanvasRenderingContextWebGL)
|
||||
DUMMY(NS_NewCanvasFloatArray, nsISupports)
|
||||
DUMMY(NS_NewCanvasByteArray, nsISupports)
|
||||
DUMMY(NS_NewCanvasUnsignedByteArray, nsISupports)
|
||||
DUMMY(NS_NewCanvasShortArray, nsISupports)
|
||||
DUMMY(NS_NewCanvasUnsignedShortArray, nsISupports)
|
||||
DUMMY(NS_NewCanvasIntArray, nsISupports)
|
||||
DUMMY(NS_NewCanvasUnsignedIntArray, nsISupports)
|
|
@ -1,4 +1,42 @@
|
|||
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2009
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Vladimir Vukicevic <vladimir@pobox.com> (original author)
|
||||
* Mark Steele <mwsteele@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "WebGLContext.h"
|
||||
|
||||
#include "prprf.h"
|
||||
|
@ -21,7 +59,6 @@
|
|||
#include "nsContentUtils.h"
|
||||
|
||||
#if 0
|
||||
// this is a toolkit service? oops.
|
||||
#include "nsIContentURIGrouper.h"
|
||||
#include "nsIContentPrefService.h"
|
||||
#endif
|
||||
|
@ -50,15 +87,12 @@ WebGLContext::SafeToCreateCanvas3DContext(nsICanvasElement *canvasElement)
|
|||
NS_ENSURE_SUCCESS(rv, PR_FALSE);
|
||||
|
||||
PRBool allSites = PR_FALSE;
|
||||
rv = prefService->GetBoolPref("layout.canvas3d.enabled_for_all_sites", &allSites);
|
||||
rv = prefService->GetBoolPref("webgl.enabled_for_all_sites", &allSites);
|
||||
if (NS_SUCCEEDED(rv) && allSites) {
|
||||
// the all-sites pref was set, we're good to go
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
// XXX fixme
|
||||
// content prefs is a toolkit component, so it's not available when we're compiling.. oops.
|
||||
|
||||
#if 0
|
||||
// otherwise we'll check content prefs
|
||||
nsCOMPtr<nsIContentPrefService> cpsvc = do_GetService("@mozilla.org/content-pref/service;1", &rv);
|
||||
|
@ -81,9 +115,9 @@ WebGLContext::SafeToCreateCanvas3DContext(nsICanvasElement *canvasElement)
|
|||
rv = principal->GetURI(getter_AddRefs(contentURI));
|
||||
NS_ENSURE_SUCCESS(rv, PR_FALSE);
|
||||
|
||||
// our pref is 'canvas3d.enabled'
|
||||
// our pref is 'webgl.enabled'
|
||||
nsCOMPtr<nsIVariant> val;
|
||||
rv = cpsvc->GetPref(contentURI, NS_LITERAL_STRING("canvas3d.enabled"), getter_AddRefs(val));
|
||||
rv = cpsvc->GetPref(contentURI, NS_LITERAL_STRING("webgl.enabled"), getter_AddRefs(val));
|
||||
NS_ENSURE_SUCCESS(rv, PR_FALSE);
|
||||
|
||||
PRInt32 iv;
|
||||
|
|
|
@ -1,4 +1,42 @@
|
|||
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2009
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Vladimir Vukicevic <vladimir@pobox.com> (original author)
|
||||
* Mark Steele <mwsteele@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "WebGLContext.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
|
|
@ -1,3 +1,41 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2009
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Vladimir Vukicevic <vladimir@pobox.com> (original author)
|
||||
* Mark Steele <mwsteele@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifdef C3D_STANDALONE_BUILD
|
||||
#include "c3d-standalone.h"
|
||||
#endif
|
||||
|
|
|
@ -1,3 +1,40 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2009
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Vladimir Vukicevic <vladimir@pobox.com> (original author)
|
||||
* Mark Steele <mwsteele@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef GLWRAP_H_
|
||||
#define GLWRAP_H_
|
||||
|
|
|
@ -1,3 +1,40 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2009
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Vladimir Vukicevic <vladimir@pobox.com> (original author)
|
||||
* Mark Steele <mwsteele@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#if !defined(LOCALGL_H_) && !defined(__gl_h_)
|
||||
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,423 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2007
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Vladimir Vukicevic <vladimir@pobox.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _NSCANVASRENDERINGCONTEXTGL_H_
|
||||
#define _NSCANVASRENDERINGCONTEXTGL_H_
|
||||
|
||||
#ifdef C3D_STANDALONE_BUILD
|
||||
#include "c3d-standalone.h"
|
||||
#endif
|
||||
|
||||
#include "nsICanvasRenderingContextGL.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "prmem.h"
|
||||
|
||||
#include "nsStringGlue.h"
|
||||
|
||||
#include "nsICanvasRenderingContextGLBuffer.h"
|
||||
#include "nsICanvasRenderingContextInternal.h"
|
||||
#include "nsIDOMHTMLCanvasElement.h"
|
||||
|
||||
#include "nsICanvasGLPrivate.h"
|
||||
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsISecurityCheckedComponent.h"
|
||||
|
||||
#include "nsWeakReference.h"
|
||||
|
||||
#include "imgIRequest.h"
|
||||
#include "imgIContainer.h"
|
||||
#include "nsIDOMHTMLCanvasElement.h"
|
||||
#include "nsICanvasElement.h"
|
||||
#include "nsIDOMHTMLImageElement.h"
|
||||
#include "nsIImageLoadingContent.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsDOMError.h"
|
||||
#include "nsIJSRuntimeService.h"
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIConsoleService.h"
|
||||
|
||||
#include "nsDOMError.h"
|
||||
|
||||
#include "nsServiceManagerUtils.h"
|
||||
|
||||
#include "nsIXPConnect.h"
|
||||
#include "jsapi.h"
|
||||
|
||||
#include "gfxContext.h"
|
||||
|
||||
#include "nsGLPbuffer.h"
|
||||
|
||||
extern nsIXPConnect *gXPConnect;
|
||||
extern JSRuntime *gScriptRuntime;
|
||||
extern nsIJSRuntimeService *gJSRuntimeService;
|
||||
|
||||
class nsICanvasRenderingContextGL;
|
||||
|
||||
class nsCanvasRenderingContextGLES11;
|
||||
class nsCanvasRenderingContextGLWeb20;
|
||||
|
||||
class CanvasGLBuffer;
|
||||
class CanvasGLTexture;
|
||||
|
||||
class nsCanvasRenderingContextGLPrivate :
|
||||
public nsICanvasRenderingContextInternal,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
friend class nsGLPbuffer;
|
||||
friend class CanvasGLBuffer;
|
||||
friend class CanvasGLTexture;
|
||||
|
||||
public:
|
||||
nsCanvasRenderingContextGLPrivate();
|
||||
virtual ~nsCanvasRenderingContextGLPrivate();
|
||||
|
||||
virtual nsICanvasRenderingContextGL *GetSelf() = 0;
|
||||
|
||||
virtual PRBool ValidateGL() { return PR_TRUE; }
|
||||
|
||||
void MakeContextCurrent();
|
||||
static void LostCurrentContext(void *closure);
|
||||
|
||||
// nsICanvasRenderingContextInternal
|
||||
NS_IMETHOD SetCanvasElement(nsICanvasElement* aParentCanvas);
|
||||
NS_IMETHOD SetDimensions(PRInt32 width, PRInt32 height);
|
||||
NS_IMETHOD Render(gfxContext *ctx, gfxPattern::GraphicsFilter f);
|
||||
NS_IMETHOD GetInputStream(const char* aMimeType,
|
||||
const PRUnichar* aEncoderOptions,
|
||||
nsIInputStream **aStream);
|
||||
NS_IMETHOD GetThebesSurface(gfxASurface **surface);
|
||||
NS_IMETHOD SetIsOpaque(PRBool b) { return NS_OK; };
|
||||
|
||||
protected:
|
||||
PRBool SafeToCreateCanvas3DContext(nsICanvasElement *canvasElement);
|
||||
nsresult DoSwapBuffers();
|
||||
|
||||
// thebes helpers
|
||||
nsresult ImageSurfaceFromElement(nsIDOMElement *imgElt,
|
||||
gfxImageSurface **aSurface,
|
||||
nsIPrincipal **prinOut,
|
||||
PRBool *forceWriteOnlyOut,
|
||||
PRBool *surfaceNeedsReleaseInsteadOfDelete);
|
||||
|
||||
void DoDrawImageSecurityCheck(nsIPrincipal* element_uri, PRBool forceWriteOnly);
|
||||
|
||||
GLES20Wrap *gl;
|
||||
|
||||
nsGLPbuffer *mGLPbuffer;
|
||||
PRInt32 mWidth, mHeight;
|
||||
nsICanvasElement* mCanvasElement;
|
||||
|
||||
PRPackedBool mPrefWireframe;
|
||||
|
||||
void LogMessage (const nsCString& errorString) {
|
||||
nsCOMPtr<nsIConsoleService> console(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
|
||||
if (!console)
|
||||
return;
|
||||
|
||||
console->LogStringMessage(NS_ConvertUTF8toUTF16(errorString).get());
|
||||
fprintf(stderr, "%s\n", errorString.get());
|
||||
}
|
||||
|
||||
void LogMessagef (const char *fmt, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
char buf[256];
|
||||
|
||||
nsCOMPtr<nsIConsoleService> console(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
|
||||
if (console) {
|
||||
vsnprintf(buf, 256, fmt, ap);
|
||||
console->LogStringMessage(NS_ConvertUTF8toUTF16(nsDependentCString(buf)).get());
|
||||
fprintf(stderr, "%s\n", buf);
|
||||
}
|
||||
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class SimpleBuffer {
|
||||
public:
|
||||
SimpleBuffer()
|
||||
: type(GL_FLOAT), data(nsnull), length(0), capacity(0), sizePerVertex(0)
|
||||
{ }
|
||||
|
||||
SimpleBuffer(PRUint32 typeParam,
|
||||
PRUint32 sizeParam,
|
||||
JSContext *ctx,
|
||||
JSObject *arrayObj,
|
||||
jsuint arrayLen)
|
||||
: type(GL_FLOAT), data(nsnull), length(0), capacity(0), sizePerVertex(0)
|
||||
{
|
||||
InitFromJSArray(typeParam, sizeParam, ctx, arrayObj, arrayLen);
|
||||
}
|
||||
|
||||
PRBool InitFromJSArray(PRUint32 typeParam,
|
||||
PRUint32 sizeParam,
|
||||
JSContext *ctx,
|
||||
JSObject *arrayObj,
|
||||
jsuint arrayLen);
|
||||
|
||||
~SimpleBuffer() {
|
||||
Release();
|
||||
}
|
||||
|
||||
inline PRBool Valid() {
|
||||
return data != nsnull;
|
||||
}
|
||||
|
||||
inline PRUint32 ElementSize() {
|
||||
if (type == GL_FLOAT) return sizeof(float);
|
||||
if (type == GL_SHORT) return sizeof(short);
|
||||
if (type == GL_UNSIGNED_SHORT) return sizeof(unsigned short);
|
||||
if (type == GL_BYTE) return 1;
|
||||
if (type == GL_UNSIGNED_BYTE) return 1;
|
||||
if (type == GL_INT) return sizeof(int);
|
||||
if (type == GL_UNSIGNED_INT) return sizeof(unsigned int);
|
||||
if (type == GL_DOUBLE) return sizeof(double);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Clear() {
|
||||
Release();
|
||||
}
|
||||
|
||||
void Set(PRUint32 t, PRUint32 spv, PRUint32 count, void* vals) {
|
||||
Prepare(t, spv, count);
|
||||
|
||||
if (count)
|
||||
memcpy(data, vals, count*ElementSize());
|
||||
}
|
||||
|
||||
void Prepare(PRUint32 t, PRUint32 spv, PRUint32 count) {
|
||||
if (count == 0) {
|
||||
Release();
|
||||
} else {
|
||||
type = t;
|
||||
EnsureCapacity(PR_FALSE, count*ElementSize());
|
||||
length = count;
|
||||
sizePerVertex = spv;
|
||||
}
|
||||
}
|
||||
|
||||
void Release() {
|
||||
if (data)
|
||||
PR_Free(data);
|
||||
length = 0;
|
||||
capacity = 0;
|
||||
data = nsnull;
|
||||
}
|
||||
|
||||
void EnsureCapacity(PRBool preserve, PRUint32 cap) {
|
||||
if (capacity >= cap)
|
||||
return;
|
||||
|
||||
void* newdata = PR_Malloc(cap);
|
||||
if (preserve && length)
|
||||
memcpy(newdata, data, length*ElementSize());
|
||||
PR_Free(data);
|
||||
data = newdata;
|
||||
capacity = cap;
|
||||
}
|
||||
|
||||
PRUint32 type;
|
||||
void* data;
|
||||
PRUint32 length; // # of elements
|
||||
PRUint32 capacity; // bytes!
|
||||
PRUint32 sizePerVertex; // OpenGL "size" param; num coordinates per vertex
|
||||
};
|
||||
|
||||
class CanvasGLTexture :
|
||||
public nsICanvasRenderingContextGLTexture,
|
||||
public nsICanvasGLTexture
|
||||
{
|
||||
friend class nsCanvasRenderingContextGLES11;
|
||||
friend class nsCanvasRenderingContextGLWeb20;
|
||||
public:
|
||||
CanvasGLTexture(nsCanvasRenderingContextGLPrivate *owner);
|
||||
~CanvasGLTexture();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_DECL_NSICANVASRENDERINGCONTEXTGLTEXTURE
|
||||
|
||||
nsresult Init();
|
||||
nsresult Dispose();
|
||||
|
||||
protected:
|
||||
PRBool mDisposed;
|
||||
nsCOMPtr<nsIWeakReference> mOwnerContext;
|
||||
|
||||
GLES20Wrap *gl;
|
||||
|
||||
PRUint32 mWidth;
|
||||
PRUint32 mHeight;
|
||||
};
|
||||
|
||||
class CanvasGLBuffer :
|
||||
public nsICanvasRenderingContextGLBuffer,
|
||||
public nsISecurityCheckedComponent,
|
||||
public nsICanvasGLBuffer
|
||||
{
|
||||
friend class nsCanvasRenderingContextGLES11;
|
||||
friend class nsCanvasRenderingContextGLWeb20;
|
||||
public:
|
||||
|
||||
CanvasGLBuffer(nsCanvasRenderingContextGLPrivate *owner);
|
||||
~CanvasGLBuffer();
|
||||
|
||||
// Init can be called multiple times to reinitialize this
|
||||
// buffer object
|
||||
nsresult Init (PRUint32 usage,
|
||||
PRUint32 size,
|
||||
PRUint32 type,
|
||||
JSContext *ctx,
|
||||
JSObject *arrayObj,
|
||||
jsuint arrayLen);
|
||||
|
||||
SimpleBuffer& GetSimpleBuffer() { return mSimpleBuffer; }
|
||||
PRBool UpdateBuffer (PRUint32 offset, SimpleBuffer& sbuffer)
|
||||
{
|
||||
PRUint32 len = GetSimpleBuffer().capacity;
|
||||
PRUint32 sbuflen = sbuffer.capacity;
|
||||
if (offset < 0 || offset > len || sbuflen > len || offset > len - sbuflen)
|
||||
return false;
|
||||
memcpy(((char*)(GetSimpleBuffer().data)) + offset, sbuffer.data, sbuflen);
|
||||
mMaxUShortComputed = false;
|
||||
return true;
|
||||
}
|
||||
GLushort MaxUShortValue()
|
||||
{
|
||||
if (!mMaxUShortComputed) {
|
||||
GLushort *data = (GLushort*)GetSimpleBuffer().data;
|
||||
PRUint32 i, len;
|
||||
GLushort max = 0;
|
||||
len = GetSimpleBuffer().capacity / sizeof(GLushort);
|
||||
for (i=0; i<len; ++i)
|
||||
if (data[i] > max)
|
||||
max = data[i];
|
||||
mMaxUShort = max;
|
||||
mMaxUShortComputed = true;
|
||||
}
|
||||
return mMaxUShort;
|
||||
}
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSICANVASRENDERINGCONTEXTGLBUFFER
|
||||
NS_DECL_NSISECURITYCHECKEDCOMPONENT
|
||||
|
||||
PRUint32 Size() { return mSize; }
|
||||
PRUint32 Length() { return mLength; }
|
||||
PRUint32 Type() { return mType; }
|
||||
|
||||
protected:
|
||||
CanvasGLBuffer() { }
|
||||
|
||||
nsCOMPtr<nsIWeakReference> mOwnerContext;
|
||||
|
||||
GLES20Wrap *gl;
|
||||
|
||||
PRBool mDisposed;
|
||||
|
||||
PRUint32 mLength;
|
||||
PRUint32 mSize;
|
||||
PRUint32 mType;
|
||||
PRUint32 mUsage;
|
||||
|
||||
SimpleBuffer mSimpleBuffer;
|
||||
GLuint mBufferID;
|
||||
|
||||
GLushort mMaxUShort;
|
||||
PRBool mMaxUShortComputed;
|
||||
};
|
||||
|
||||
class CanvasGLThebes {
|
||||
public:
|
||||
static gfxImageSurface *CreateImageSurface (const gfxIntSize &isize,
|
||||
gfxASurface::gfxImageFormat fmt);
|
||||
|
||||
static gfxContext *CreateContext (gfxASurface *surf);
|
||||
|
||||
static gfxPattern *CreatePattern (gfxASurface *surf);
|
||||
};
|
||||
|
||||
/* Helper macros for when we're just wrapping a gl method, so that
|
||||
* we can avoid having to type this 500 times. Note that these MUST
|
||||
* NOT BE USED if we need to check any of the parameters.
|
||||
*/
|
||||
|
||||
#define GL_SAME_METHOD_0(glname, name) \
|
||||
NS_IMETHODIMP NSGL_CONTEXT_NAME::name() { \
|
||||
MakeContextCurrent(); gl->f##glname(); return NS_OK; \
|
||||
}
|
||||
|
||||
#define GL_SAME_METHOD_1(glname, name, t1) \
|
||||
NS_IMETHODIMP NSGL_CONTEXT_NAME::name(t1 a1) { \
|
||||
MakeContextCurrent(); gl->f##glname(a1); return NS_OK; \
|
||||
}
|
||||
|
||||
#define GL_SAME_METHOD_2(glname, name, t1, t2) \
|
||||
NS_IMETHODIMP NSGL_CONTEXT_NAME::name(t1 a1, t2 a2) { \
|
||||
MakeContextCurrent(); gl->f##glname(a1,a2); return NS_OK; \
|
||||
}
|
||||
|
||||
#define GL_SAME_METHOD_3(glname, name, t1, t2, t3) \
|
||||
NS_IMETHODIMP NSGL_CONTEXT_NAME::name(t1 a1, t2 a2, t3 a3) { \
|
||||
MakeContextCurrent(); gl->f##glname(a1,a2,a3); return NS_OK; \
|
||||
}
|
||||
|
||||
#define GL_SAME_METHOD_4(glname, name, t1, t2, t3, t4) \
|
||||
NS_IMETHODIMP NSGL_CONTEXT_NAME::name(t1 a1, t2 a2, t3 a3, t4 a4) { \
|
||||
MakeContextCurrent(); gl->f##glname(a1,a2,a3,a4); return NS_OK; \
|
||||
}
|
||||
|
||||
#define GL_SAME_METHOD_5(glname, name, t1, t2, t3, t4, t5) \
|
||||
NS_IMETHODIMP NSGL_CONTEXT_NAME::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5) { \
|
||||
MakeContextCurrent(); gl->f##glname(a1,a2,a3,a4,a5); return NS_OK; \
|
||||
}
|
||||
|
||||
#define GL_SAME_METHOD_6(glname, name, t1, t2, t3, t4, t5, t6) \
|
||||
NS_IMETHODIMP NSGL_CONTEXT_NAME::name(t1 a1, t2 a2, t3 a3, t4 a4, t5 a5, t6 a6) { \
|
||||
MakeContextCurrent(); gl->f##glname(a1,a2,a3,a4,a5,a6); return NS_OK; \
|
||||
}
|
||||
|
||||
#endif /* _NSCANVASRENDERINGCONTEXTGL_H_ */
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -670,24 +670,11 @@ interface nsICanvasRenderingContextWebGL : nsISupports
|
|||
|
||||
void cullFace (in GLenum mode);
|
||||
|
||||
// Modified: void glDeleteBuffers (GLsizei n, const GLuint* buffers);
|
||||
//ZZ void deleteBuffer (in nsIWebGLBuffer buffer);
|
||||
void deleteBuffer (in nsIWebGLBuffer buffer);
|
||||
|
||||
// Modified: glDeleteFramebuffers (GLsizei n, const GLuint* framebuffers);
|
||||
//ZZ void deleteFramebuffer (in nsIWebGLFramebuffer framebuffer);
|
||||
void deleteFramebuffer (in nsIWebGLFramebuffer framebuffer);
|
||||
|
||||
void deleteProgram (in nsIWebGLProgram program);
|
||||
|
||||
// Modified: void glDeleteRenderbuffers (GLsizei n, const GLuint* renderbuffers);
|
||||
//ZZ void deleteRenderbuffer (in nsIWebGLRenderbuffer renderbuffer);
|
||||
void deleteFramebuffer (in nsIWebGLFramebuffer framebuffer);
|
||||
void deleteRenderbuffer (in nsIWebGLRenderbuffer renderbuffer);
|
||||
|
||||
void deleteShader (in nsIWebGLShader shader);
|
||||
|
||||
// Modified: void glDeleteTextures (GLsizei n, const GLuint* textures);
|
||||
//ZZ void deleteTexture (in nsIWebGLTexture texture);
|
||||
void deleteTexture (in nsIWebGLTexture texture);
|
||||
|
||||
void depthFunc (in GLenum func);
|
||||
|
@ -713,24 +700,7 @@ interface nsICanvasRenderingContextWebGL : nsISupports
|
|||
|
||||
void generateMipmap (in GLenum target);
|
||||
|
||||
//ZZ in the spec these are all createBuffer/createFramebuffer/etc.
|
||||
// Modified: void glGenBuffers (GLsizei n, GLuint* buffers);
|
||||
//nsIWebGLBuffer genBuffer();
|
||||
// Modified: void glGenFramebuffers (GLsizei n, GLuint* framebuffers);
|
||||
//nsIWebGLFramebuffer genFramebuffer();
|
||||
// Modified: void glGenRenderbuffers (GLsizei n, GLuint* renderbuffers);
|
||||
//nsIWebGLRenderbuffer genRenderbuffer();
|
||||
// Modified: void glGenTextures (GLsizei n, GLuint* textures);
|
||||
//nsIWebGLTexture genTexture();
|
||||
|
||||
// TBD
|
||||
//void glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size,
|
||||
// GLenum* type, char* name);
|
||||
nsIWebGLActiveInfo getActiveAttrib(in nsIWebGLProgram program, in PRUint32 index);
|
||||
|
||||
// TBD
|
||||
//void glGetActiveUniform (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size,
|
||||
// GLenum* type, char* name);
|
||||
nsIWebGLActiveInfo getActiveUniform(in nsIWebGLProgram program, in PRUint32 index);
|
||||
|
||||
// TBD
|
||||
|
|
|
@ -103,7 +103,7 @@ SHARED_LIBRARY_LIBS = \
|
|||
$(DEPTH)/dom/src/jsurl/$(LIB_PREFIX)jsurl_s.$(LIB_SUFFIX) \
|
||||
$(DEPTH)/dom/src/storage/$(LIB_PREFIX)jsdomstorage_s.$(LIB_SUFFIX) \
|
||||
$(DEPTH)/dom/src/offline/$(LIB_PREFIX)jsdomoffline_s.$(LIB_SUFFIX) \
|
||||
$(DEPTH)/dom/src/geolocation/$(LIB_PREFIX)jsdomgeolocation_s.$(LIB_SUFFIX) \
|
||||
$(DEPTH)/dom/src/geolocation/$(LIB_PREFIX)jsdomgeolocation_s.$(LIB_SUFFIX) \
|
||||
$(DEPTH)/dom/src/threads/$(LIB_PREFIX)domthreads_s.$(LIB_SUFFIX) \
|
||||
$(DEPTH)/editor/libeditor/text/$(LIB_PREFIX)texteditor_s.$(LIB_SUFFIX) \
|
||||
$(DEPTH)/editor/libeditor/base/$(LIB_PREFIX)editorbase_s.$(LIB_SUFFIX) \
|
||||
|
@ -228,7 +228,13 @@ ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
|
|||
EXTRA_DSO_LDOPTS += $(TK_LIBS)
|
||||
|
||||
ifdef MOZ_ENABLE_CANVAS3D
|
||||
EXTRA_DSO_LDOPTS += -framework OpenGL
|
||||
OS_LIBS += -framework OpenGL
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq (,$(filter windows,$(MOZ_WIDGET_TOOLKIT)))
|
||||
ifdef MOZ_ENABLE_CANVAS3D
|
||||
OS_LIBS += opengl32.lib
|
||||
endif
|
||||
endif
|
||||
|
||||
|
|
|
@ -2761,6 +2761,9 @@ pref("image.cache.timeweight", 500);
|
|||
// The default Accept header sent for images loaded over HTTP(S)
|
||||
pref("image.http.accept", "image/png,image/*;q=0.8,*/*;q=0.5");
|
||||
|
||||
// WebGL global enable flag
|
||||
pref("webgl.enabled_for_all_sites", false);
|
||||
|
||||
#ifdef XP_WIN
|
||||
#ifndef WINCE
|
||||
// The default TCP send window on Windows is too small, and autotuning only occurs on receive
|
||||
|
|
Загрузка…
Ссылка в новой задаче