Commit f493aa2a authored by cmarrin@apple.com's avatar cmarrin@apple.com

Added all new Canvas3D files to the build

        https://bugs.webkit.org/show_bug.cgi?id=28018

        This also hooks up CanvasRenderingContext as the common base class for
        CanvasRenderingContext2D and CanvasRenderingContext3D. And it adds a bit
        of logic throughout to support the new CanvasRenderingContext3D object.
        But nothing is hooked up yet.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@47752 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent d56e0692
2009-08-25 Chris Marrin <cmarrin@apple.com>
Reviewed by Simon Fraser.
Export tryFastMalloc for Canvas3D work
https://bugs.webkit.org/show_bug.cgi?id=28018
* JavaScriptCore.exp:
2009-08-25 David Levin <levin@chromium.org>
Reviewed by Adam Roben.
......
......@@ -278,6 +278,7 @@ __ZN3JSCgtERKNS_7UStringES2_
__ZN3JSCltERKNS_7UStringES2_
__ZN3WTF10fastCallocEmm
__ZN3WTF10fastMallocEm
__ZN3WTF13tryFastMallocEm
__ZN3WTF11currentTimeEv
__ZN3WTF11fastReallocEPvm
__ZN3WTF12createThreadEPFPvS0_ES0_
......
2009-08-25 Chris Marrin <cmarrin@apple.com>
Reviewed by Simon Fraser.
Fixed one test which changed due to different inheritance of CanvasRenderingContext2D
https://bugs.webkit.org/show_bug.cgi?id=28018
* fast/dom/prototype-inheritance-2-expected.txt:
2009-08-25 Renata Hodovan <hodovan.renata@stud.u-szeged.hu>
Reviewed by Ariya Hidayat.
......
......@@ -49,6 +49,7 @@ FAIL CanvasPatternPrototype from inner.document.getElementsByTagName("canvas")[0
PASS CanvasRenderingContext2D from inner.document.getElementsByTagName("canvas")[0].getContext("2d")
PASS CanvasRenderingContext2DConstructor from inner.document.getElementsByTagName("canvas")[0].getContext("2d").constructor
PASS CanvasRenderingContext2DPrototype from inner.document.getElementsByTagName("canvas")[0].getContext("2d").__proto__
PASS CanvasRenderingContextPrototype from inner.document.getElementsByTagName("canvas")[0].getContext("2d").__proto__.__proto__
PASS CharacterDataPrototype from inner.document.activeElement.childNodes.61.__proto__.__proto__
PASS ClientRect from inner.document.body.getBoundingClientRect()
PASS ClientRectConstructor from inner.document.body.getBoundingClientRect().constructor
......
2009-08-25 Chris Marrin <cmarrin@apple.com>
Reviewed by Simon Fraser.
Added all new Canvas3D files to the build
https://bugs.webkit.org/show_bug.cgi?id=28018
This also hooks up CanvasRenderingContext as the common base class for
CanvasRenderingContext2D and CanvasRenderingContext3D. And it adds a bit
of logic throughout to support the new CanvasRenderingContext3D object.
But nothing is hooked up yet.
* DerivedSources.make:
* WebCore.pro:
* WebCore.vcproj/WebCore.vcproj:
* WebCore/GNUmakefile.am:
* WebCore/WebCore.gypi:
* WebCore/WebCoreSources.bkl:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSCanvasRenderingContext2DCustom.cpp:
(WebCore::JSCanvasRenderingContext2D::strokeStyle):
(WebCore::JSCanvasRenderingContext2D::setStrokeStyle):
(WebCore::JSCanvasRenderingContext2D::fillStyle):
(WebCore::JSCanvasRenderingContext2D::setFillStyle):
(WebCore::JSCanvasRenderingContext2D::setFillColor):
(WebCore::JSCanvasRenderingContext2D::setStrokeColor):
(WebCore::JSCanvasRenderingContext2D::strokeRect):
(WebCore::JSCanvasRenderingContext2D::drawImage):
(WebCore::JSCanvasRenderingContext2D::drawImageFromRect):
(WebCore::JSCanvasRenderingContext2D::setShadow):
(WebCore::JSCanvasRenderingContext2D::createPattern):
(WebCore::JSCanvasRenderingContext2D::putImageData):
(WebCore::JSCanvasRenderingContext2D::fillText):
(WebCore::JSCanvasRenderingContext2D::strokeText):
* bindings/js/JSDOMBinding.cpp:
(WebCore::isObservableThroughDOM):
* bindings/js/JSDocumentCustom.cpp:
* bindings/js/JSHTMLCanvasElementCustom.cpp:
(WebCore::JSHTMLCanvasElement::markChildren):
* dom/Document.cpp:
(WebCore::Document::getCSSCanvasContext):
* dom/Document.h:
* html/HTMLCanvasElement.cpp:
(WebCore::HTMLCanvasElement::getContext):
(WebCore::HTMLCanvasElement::willDraw):
(WebCore::HTMLCanvasElement::reset):
(WebCore::HTMLCanvasElement::paint):
(WebCore::HTMLCanvasElement::is3D):
(WebCore::HTMLCanvasElement::context3D):
(WebCore::HTMLCanvasElement::texture3D):
* html/HTMLCanvasElement.h:
(WebCore::HTMLCanvasElement::renderingContext):
* html/canvas/CanvasObject.cpp:
(WebCore::CanvasObject::~CanvasObject):
* html/canvas/CanvasRenderingContext.idl:
* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::CanvasRenderingContext2D):
(WebCore::CanvasRenderingContext2D::~CanvasRenderingContext2D):
* html/canvas/CanvasRenderingContext2D.h:
(WebCore::CanvasRenderingContext2D::is2d):
* html/canvas/CanvasRenderingContext2D.idl:
* html/canvas/CanvasRenderingContext3D.cpp:
* html/canvas/CanvasRenderingContext3D.idl:
2009-08-25 Dan Bernstein <mitz@apple.com>
Reviewed by Anders Carlsson.
......@@ -30,7 +30,11 @@
#include "JSBarInfo.cpp"
#include "JSCanvasGradient.cpp"
#include "JSCanvasPattern.cpp"
#include "JSCanvasRenderingContext.cpp"
#include "JSCanvasRenderingContext2D.cpp"
#if ENABLE(3D_CANVAS)
#include "JSCanvasRenderingContext3D.cpp"
#endif
#include "JSCDATASection.cpp"
#include "JSCharacterData.cpp"
#include "JSClientRect.cpp"
......
......@@ -68,9 +68,19 @@ DOM_CLASSES = \
CSSValueList \
CSSVariablesRule \
CSSVariablesDeclaration \
CanvasBuffer \
CanvasByteArray \
CanvasFramebuffer \
CanvasGradient \
CanvasNumberArray \
CanvasPattern \
CanvasProgram \
CanvasRenderbuffer \
CanvasRenderingContext \
CanvasRenderingContext2D \
CanvasRenderingContext3D \
CanvasShader \
CanvasTexture \
CharacterData \
ClientRect \
ClientRectList \
......
......@@ -151,6 +151,7 @@ IDL_BINDINGS += \
WebCore/dom/WheelEvent.idl \
WebCore/html/canvas/CanvasGradient.idl \
WebCore/html/canvas/CanvasPattern.idl \
WebCore/html/canvas/CanvasRenderingContext.idl \
WebCore/html/canvas/CanvasRenderingContext2D.idl \
WebCore/html/DataGridColumn.idl \
WebCore/html/DataGridColumnList.idl \
......@@ -316,6 +317,7 @@ webcore_sources += \
WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp \
WebCore/bindings/js/JSCSSStyleDeclarationCustom.h \
WebCore/bindings/js/JSCSSValueCustom.cpp \
WebCore/bindings/js/JSCanvasRenderingContextCustom.cpp \
WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp \
WebCore/bindings/js/JSClipboardCustom.cpp \
WebCore/bindings/js/JSConsoleCustom.cpp \
......@@ -913,6 +915,8 @@ webcore_sources += \
WebCore/html/canvas/CanvasPattern.h \
WebCore/html/canvas/CanvasPixelArray.cpp \
WebCore/html/canvas/CanvasPixelArray.h \
WebCore/html/canvas/CanvasRenderingContext.cpp \
WebCore/html/canvas/CanvasRenderingContext.h \
WebCore/html/canvas/CanvasRenderingContext2D.cpp \
WebCore/html/canvas/CanvasRenderingContext2D.h \
WebCore/html/canvas/CanvasStyle.cpp \
......
......@@ -78,6 +78,7 @@
'html/canvas/CanvasGradient.idl',
'html/canvas/CanvasPattern.idl',
'html/canvas/CanvasPixelArray.idl',
'html/canvas/CanvasRenderingContext.idl',
'html/canvas/CanvasRenderingContext2D.idl',
'html/DataGridColumn.idl',
'html/DataGridColumnList.idl',
......@@ -411,6 +412,7 @@
'bindings/js/JSAttrCustom.cpp',
'bindings/js/JSAudioConstructor.cpp',
'bindings/js/JSAudioConstructor.h',
'bindings/js/JSCanvasRenderingContextCustom.cpp',
'bindings/js/JSCanvasRenderingContext2DCustom.cpp',
'bindings/js/JSCDATASectionCustom.cpp',
'bindings/js/JSClipboardCustom.cpp',
......@@ -1215,6 +1217,8 @@
'html/canvas/CanvasPattern.h',
'html/canvas/CanvasPixelArray.cpp',
'html/canvas/CanvasPixelArray.h',
'html/canvas/CanvasRenderingContext.cpp',
'html/canvas/CanvasRenderingContext.h',
'html/canvas/CanvasRenderingContext2D.cpp',
'html/canvas/CanvasRenderingContext2D.h',
'html/canvas/CanvasStyle.cpp',
......
......@@ -361,6 +361,7 @@ IDL_BINDINGS += \
dom/WheelEvent.idl \
html/canvas/CanvasGradient.idl \
html/canvas/CanvasPattern.idl \
html/canvas/CanvasRenderingContext.idl \
html/canvas/CanvasRenderingContext2D.idl \
html/DataGridColumn.idl \
html/DataGridColumnList.idl \
......@@ -644,6 +645,7 @@ SOURCES += \
bindings/js/GCController.cpp \
bindings/js/JSAttrCustom.cpp \
bindings/js/JSCDATASectionCustom.cpp \
bindings/js/JSCanvasRenderingContextCustom.cpp \
bindings/js/JSCanvasRenderingContext2DCustom.cpp \
bindings/js/JSClipboardCustom.cpp \
bindings/js/JSConsoleCustom.cpp \
......@@ -944,6 +946,7 @@ SOURCES += \
html/canvas/CanvasGradient.cpp \
html/canvas/CanvasPattern.cpp \
html/canvas/CanvasPixelArray.cpp \
html/canvas/CanvasRenderingContext.cpp \
html/canvas/CanvasRenderingContext2D.cpp \
html/canvas/CanvasStyle.cpp \
html/CollectionCache.cpp \
......@@ -1603,6 +1606,7 @@ HEADERS += \
html/canvas/CanvasGradient.h \
html/canvas/CanvasPattern.h \
html/canvas/CanvasPixelArray.h \
html/canvas/CanvasRenderingContext.h \
html/canvas/CanvasRenderingContext2D.h \
html/canvas/CanvasStyle.h \
html/CollectionCache.h \
......
......@@ -662,6 +662,54 @@
RelativePath="$(WebKitOutputDir)\obj\$(ProjectName)\DerivedSources\JSCanvasPattern.h"
>
</File>
<File
RelativePath="$(WebKitOutputDir)\obj\$(ProjectName)\DerivedSources\JSCanvasRenderingContext.cpp"
>
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug_Internal|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug_Cairo|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Release_Cairo|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath="$(WebKitOutputDir)\obj\$(ProjectName)\DerivedSources\JSCanvasRenderingContext.h"
>
</File>
<File
RelativePath="$(WebKitOutputDir)\obj\$(ProjectName)\DerivedSources\JSCanvasRenderingContext2D.cpp"
>
......@@ -24883,6 +24931,14 @@
RelativePath="..\html\canvas\CanvasPixelArray.h"
>
</File>
<File
RelativePath="..\html\canvas\CanvasRenderingContext.cpp"
>
</File>
<File
RelativePath="..\html\canvas\CanvasRenderingContext.h"
>
</File>
<File
RelativePath="..\html\canvas\CanvasRenderingContext2D.cpp"
>
......@@ -28622,6 +28678,10 @@
RelativePath="..\bindings\js\JSAudioConstructor.h"
>
</File>
<File
RelativePath="..\bindings\js\JSCanvasRenderingContextCustom.cpp"
>
</File>
<File
RelativePath="..\bindings\js\JSCanvasRenderingContext2DCustom.cpp"
>
......
This diff is collapsed.
......@@ -56,6 +56,7 @@ This file contains the list of files needed to build WebCore.
bindings/js/JSAttrCustom.cpp
bindings/js/JSAudioConstructor.cpp
bindings/js/JSCDATASectionCustom.cpp
bindings/js/JSCanvasRenderingContextCustom.cpp
bindings/js/JSCanvasRenderingContext2DCustom.cpp
bindings/js/JSClipboardCustom.cpp
bindings/js/JSConsoleCustom.cpp
......@@ -264,6 +265,7 @@ This file contains the list of files needed to build WebCore.
DerivedSources/WebCore/JSCSSVariablesRule.cpp
DerivedSources/WebCore/JSCanvasGradient.cpp
DerivedSources/WebCore/JSCanvasPattern.cpp
DerivedSources/WebCore/JSCanvasRenderingContext.cpp
DerivedSources/WebCore/JSCanvasRenderingContext2D.cpp
DerivedSources/WebCore/JSCharacterData.cpp
DerivedSources/WebCore/JSClientRect.cpp
......@@ -576,6 +578,7 @@ This file contains the list of files needed to build WebCore.
html/canvas/CanvasGradient.cpp
html/canvas/CanvasPattern.cpp
html/canvas/CanvasPixelArray.cpp
html/canvas/CanvasRenderingContext.cpp
html/canvas/CanvasRenderingContext2D.cpp
html/canvas/CanvasStyle.cpp
html/CollectionCache.cpp
......
......@@ -67,27 +67,31 @@ static PassRefPtr<CanvasStyle> toHTMLCanvasStyle(ExecState*, JSValue value)
JSValue JSCanvasRenderingContext2D::strokeStyle(ExecState* exec) const
{
return toJS(exec, impl()->strokeStyle());
CanvasRenderingContext2D* context = static_cast<CanvasRenderingContext2D*>(impl());
return toJS(exec, context->strokeStyle());
}
void JSCanvasRenderingContext2D::setStrokeStyle(ExecState* exec, JSValue value)
{
impl()->setStrokeStyle(toHTMLCanvasStyle(exec, value));
CanvasRenderingContext2D* context = static_cast<CanvasRenderingContext2D*>(impl());
context->setStrokeStyle(toHTMLCanvasStyle(exec, value));
}
JSValue JSCanvasRenderingContext2D::fillStyle(ExecState* exec) const
{
return toJS(exec, impl()->fillStyle());
CanvasRenderingContext2D* context = static_cast<CanvasRenderingContext2D*>(impl());
return toJS(exec, context->fillStyle());
}
void JSCanvasRenderingContext2D::setFillStyle(ExecState* exec, JSValue value)
{
impl()->setFillStyle(toHTMLCanvasStyle(exec, value));
CanvasRenderingContext2D* context = static_cast<CanvasRenderingContext2D*>(impl());
context->setFillStyle(toHTMLCanvasStyle(exec, value));
}
JSValue JSCanvasRenderingContext2D::setFillColor(ExecState* exec, const ArgList& args)
{
CanvasRenderingContext2D* context = impl();
CanvasRenderingContext2D* context = static_cast<CanvasRenderingContext2D*>(impl());
// string arg = named color
// number arg = gray color
......@@ -124,7 +128,7 @@ JSValue JSCanvasRenderingContext2D::setFillColor(ExecState* exec, const ArgList&
JSValue JSCanvasRenderingContext2D::setStrokeColor(ExecState* exec, const ArgList& args)
{
CanvasRenderingContext2D* context = impl();
CanvasRenderingContext2D* context = static_cast<CanvasRenderingContext2D*>(impl());
// string arg = named color
// number arg = gray color
......@@ -162,7 +166,7 @@ JSValue JSCanvasRenderingContext2D::setStrokeColor(ExecState* exec, const ArgLis
JSValue JSCanvasRenderingContext2D::strokeRect(ExecState* exec, const ArgList& args)
{
CanvasRenderingContext2D* context = impl();
CanvasRenderingContext2D* context = static_cast<CanvasRenderingContext2D*>(impl());
if (args.size() <= 4)
context->strokeRect(args.at(0).toFloat(exec), args.at(1).toFloat(exec),
......@@ -176,7 +180,7 @@ JSValue JSCanvasRenderingContext2D::strokeRect(ExecState* exec, const ArgList& a
JSValue JSCanvasRenderingContext2D::drawImage(ExecState* exec, const ArgList& args)
{
CanvasRenderingContext2D* context = impl();
CanvasRenderingContext2D* context = static_cast<CanvasRenderingContext2D*>(impl());
// DrawImage has three variants:
// drawImage(img, dx, dy)
......@@ -264,7 +268,7 @@ JSValue JSCanvasRenderingContext2D::drawImage(ExecState* exec, const ArgList& ar
JSValue JSCanvasRenderingContext2D::drawImageFromRect(ExecState* exec, const ArgList& args)
{
CanvasRenderingContext2D* context = impl();
CanvasRenderingContext2D* context = static_cast<CanvasRenderingContext2D*>(impl());
JSValue value = args.at(0);
if (!value.isObject())
......@@ -284,7 +288,7 @@ JSValue JSCanvasRenderingContext2D::drawImageFromRect(ExecState* exec, const Arg
JSValue JSCanvasRenderingContext2D::setShadow(ExecState* exec, const ArgList& args)
{
CanvasRenderingContext2D* context = impl();
CanvasRenderingContext2D* context = static_cast<CanvasRenderingContext2D*>(impl());
switch (args.size()) {
case 3:
......@@ -330,7 +334,7 @@ JSValue JSCanvasRenderingContext2D::setShadow(ExecState* exec, const ArgList& ar
JSValue JSCanvasRenderingContext2D::createPattern(ExecState* exec, const ArgList& args)
{
CanvasRenderingContext2D* context = impl();
CanvasRenderingContext2D* context = static_cast<CanvasRenderingContext2D*>(impl());
JSValue value = args.at(0);
if (!value.isObject())
......@@ -362,7 +366,7 @@ JSValue JSCanvasRenderingContext2D::putImageData(ExecState* exec, const ArgList&
// putImageData has two variants
// putImageData(ImageData, x, y)
// putImageData(ImageData, x, y, dirtyX, dirtyY, dirtyWidth, dirtyHeight)
CanvasRenderingContext2D* context = impl();
CanvasRenderingContext2D* context = static_cast<CanvasRenderingContext2D*>(impl());
ExceptionCode ec = 0;
if (args.size() >= 7)
......@@ -377,7 +381,7 @@ JSValue JSCanvasRenderingContext2D::putImageData(ExecState* exec, const ArgList&
JSValue JSCanvasRenderingContext2D::fillText(ExecState* exec, const ArgList& args)
{
CanvasRenderingContext2D* context = impl();
CanvasRenderingContext2D* context = static_cast<CanvasRenderingContext2D*>(impl());
// string arg = text to draw
// number arg = x
......@@ -395,7 +399,7 @@ JSValue JSCanvasRenderingContext2D::fillText(ExecState* exec, const ArgList& arg
JSValue JSCanvasRenderingContext2D::strokeText(ExecState* exec, const ArgList& args)
{
CanvasRenderingContext2D* context = impl();
CanvasRenderingContext2D* context = static_cast<CanvasRenderingContext2D*>(impl());
// string arg = text to draw
// number arg = x
......
......@@ -298,7 +298,7 @@ static inline bool isObservableThroughDOM(JSNode* jsNode)
}
}
if (static_cast<Element*>(node)->hasTagName(canvasTag)) {
if (CanvasRenderingContext2D* context = static_cast<HTMLCanvasElement*>(node)->renderingContext2D()) {
if (CanvasRenderingContext* context = static_cast<HTMLCanvasElement*>(node)->renderingContext()) {
if (DOMObject* wrapper = getCachedDOMObjectWrapper(*jsNode->globalObject()->globalData(), context)) {
if (wrapper->hasCustomProperties())
return true;
......
......@@ -24,6 +24,10 @@
#include "Frame.h"
#include "FrameLoader.h"
#include "HTMLDocument.h"
#include "JSCanvasRenderingContext2D.h"
#if ENABLE(3D_CANVAS)
#include "JSCanvasRenderingContext3D.h"
#endif
#include "JSDOMWindowCustom.h"
#include "JSHTMLDocument.h"
#include "JSLocation.h"
......@@ -35,6 +39,8 @@
#include "SVGDocument.h"
#endif
#include <wtf/GetPtr.h>
using namespace JSC;
namespace WebCore {
......
......@@ -30,28 +30,13 @@
#include "JSCanvasRenderingContext2D.h"
#if ENABLE(3D_CANVAS)
#include "JSCanvasRenderingContext3D.h"
#include <wtf/GetPtr.h>
#endif
#include <wtf/GetPtr.h>
using namespace JSC;
namespace WebCore {
#if ENABLE(3D_CANVAS)
JSValue JSHTMLCanvasElement::getContext(JSC::ExecState* exec, JSC::ArgList const& args)
{
HTMLCanvasElement* imp = static_cast<HTMLCanvasElement*>(impl());
const UString& contextId = args.at(0).toString(exec);
if (contextId == "2d")
return toJS(exec, WTF::getPtr(reinterpret_cast<CanvasRenderingContext2D*>(imp->getContext(contextId))));
if (contextId == "webkit-3d")
return toJS(exec, WTF::getPtr(reinterpret_cast<CanvasRenderingContext3D*>(imp->getContext(contextId))));
return jsUndefined();
}
#endif
void JSHTMLCanvasElement::markChildren(MarkStack& markStack)
{
Base::markChildren(markStack);
......@@ -59,7 +44,7 @@ void JSHTMLCanvasElement::markChildren(MarkStack& markStack)
HTMLCanvasElement* canvas = static_cast<HTMLCanvasElement*>(impl());
JSGlobalData& globalData = *Heap::heap(this)->globalData();
markDOMObjectWrapper(markStack, globalData, canvas->renderingContext2D());
markDOMObjectWrapper(markStack, globalData, canvas->renderingContext());
}
} // namespace WebCore
......@@ -4332,7 +4332,7 @@ void Document::detachRange(Range* range)
m_ranges.remove(range);
}
CanvasRenderingContext2D* Document::getCSSCanvasContext(const String& type, const String& name, int width, int height)
CanvasRenderingContext* Document::getCSSCanvasContext(const String& type, const String& name, int width, int height)
{
HTMLCanvasElement* result = getCSSCanvasElement(name);
if (!result)
......
......@@ -53,7 +53,7 @@ namespace WebCore {
class CDATASection;
class CachedCSSStyleSheet;
class CachedScript;
class CanvasRenderingContext2D;
class CanvasRenderingContext;
class CharacterData;
class CSSStyleDeclaration;
class CSSStyleSelector;
......@@ -759,7 +759,7 @@ public:
DOMSelection* getSelection() const;
// Extension for manipulating canvas drawing contexts for use in CSS
CanvasRenderingContext2D* getCSSCanvasContext(const String& type, const String& name, int width, int height);
CanvasRenderingContext* getCSSCanvasContext(const String& type, const String& name, int width, int height);
HTMLCanvasElement* getCSSCanvasElement(const String& name);
bool isDNSPrefetchEnabled() const { return m_isDNSPrefetchEnabled; }
......
......@@ -30,6 +30,7 @@
#include "CanvasGradient.h"
#include "CanvasPattern.h"
#include "CanvasRenderingContext2D.h"
#include "CanvasRenderingContext3D.h"
#include "CanvasStyle.h"
#include "Chrome.h"
#include "Document.h"
......@@ -146,17 +147,36 @@ String HTMLCanvasElement::toDataURL(const String& mimeType, ExceptionCode& ec)
CanvasRenderingContext* HTMLCanvasElement::getContext(const String& type)
{
// A Canvas can either be "2D" or "3D" never both. If you request a 2D canvas and the existing
// context is already 2D, just return that. If the existing context is 3D, then destroy it
// before creating a new 2D context. Vice versa when requesting a 3D canvas. Requesting a
// context with any other type string will destroy any existing context.
if (type == "2d") {
if (!m_2DContext)
m_2DContext.set(new CanvasRenderingContext2D(this));
return m_2DContext.get();
if (m_context && !m_context->is2d())
m_context.clear();
if (!m_context)
m_context.set(new CanvasRenderingContext2D(this));
}
return 0;
#if ENABLE(3D_CANVAS)
else if (type == "webkit-3d") {
if (m_context && !m_context->is3d())
m_context.clear();
if (!m_context) {
m_context.set(new CanvasRenderingContext3D(this));
setNeedsStyleRecalc();
}
}
#endif
else if (m_context)
m_context.clear();
return m_context.get();
}
void HTMLCanvasElement::willDraw(const FloatRect& rect)
{
m_imageBuffer->clearImage();
if (m_imageBuffer)
m_imageBuffer->clearImage();
if (RenderBox* ro = renderBox()) {
FloatRect destRect = ro->contentBoxRect();
......@@ -192,8 +212,8 @@ void HTMLCanvasElement::reset()
bool hadImageBuffer = m_createdImageBuffer;
m_createdImageBuffer = false;
m_imageBuffer.clear();
if (m_2DContext)
m_2DContext->reset();
if (m_context && m_context->is2d())
static_cast<CanvasRenderingContext2D*>(m_context.get())->reset();
if (RenderObject* renderer = this->renderer()) {
if (m_rendererIsCanvas) {
......@@ -221,6 +241,11 @@ void HTMLCanvasElement::paint(GraphicsContext* context, const IntRect& r)
if (image)
context->drawImage(image, r);
}
#if ENABLE(3D_CANVAS)
if (m_context && m_context->is3d())
static_cast<CanvasRenderingContext3D*>(m_context.get())->reshape(r.width(), r.height());
#endif
}
IntRect HTMLCanvasElement::convertLogicalToDevice(const FloatRect& logicalRect) const
......@@ -293,4 +318,25 @@ TransformationMatrix HTMLCanvasElement::baseTransform() const
return transform;
}
#if ENABLE(3D_CANVAS)
bool HTMLCanvasElement::is3D() const
{
return m_context && m_context->is3d();
}
PlatformGraphicsContext3D HTMLCanvasElement::context3D() const
{
if (m_context && m_context->is3d())
return static_cast<CanvasRenderingContext3D*>(m_context.get())->context3D();
return 0;
}
Platform3DObject HTMLCanvasElement::texture3D() const
{
if (m_context && m_context->is3d())
return static_cast<CanvasRenderingContext3D*>(m_context.get())->texture3D();
return 0;
}
#endif
}
......@@ -30,11 +30,14 @@
#include "TransformationMatrix.h"
#include "FloatRect.h"
#include "HTMLElement.h"
#if ENABLE(3D_CANVAS)
#include "GraphicsContext3D.h"
#endif
#include "IntSize.h"
namespace WebCore {
class CanvasRenderingContext2D;
class CanvasRenderingContext;
class FloatPoint;
class FloatRect;
class FloatSize;
......@@ -44,8 +47,6 @@ class ImageBuffer;
class IntPoint;
class IntSize;
typedef CanvasRenderingContext2D CanvasRenderingContext;
class CanvasObserver {
public:
virtual ~CanvasObserver() { }
......@@ -100,7 +101,13 @@ public:
TransformationMatrix baseTransform() const;
CanvasRenderingContext2D* renderingContext2D() { return m_2DContext.get(); }
CanvasRenderingContext* renderingContext() const { return m_context.get(); }
#if ENABLE(3D_CANVAS)
bool is3D() const;
PlatformGraphicsContext3D context3D() const;
Platform3DObject texture3D() const;
#endif
private:
#if ENABLE(DASHBOARD_SUPPORT)
......@@ -118,7 +125,7 @@ private:
bool m_rendererIsCanvas;
OwnPtr<CanvasRenderingContext2D> m_2DContext;
OwnPtr<CanvasRenderingContext>