summaryrefslogtreecommitdiffstats
path: root/WebKit/chromium/src/GraphicsContext3D.cpp
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2010-07-08 12:51:48 +0100
committerSteve Block <steveblock@google.com>2010-07-09 15:33:40 +0100
commitca9cb53ed1119a3fd98fafa0972ffeb56dee1c24 (patch)
treebb45155550ec013adc0ad10f4d7d354c6469b022 /WebKit/chromium/src/GraphicsContext3D.cpp
parentd4b24d9a829ed7de70381c8b99fb75a07ab40466 (diff)
downloadexternal_webkit-ca9cb53ed1119a3fd98fafa0972ffeb56dee1c24.zip
external_webkit-ca9cb53ed1119a3fd98fafa0972ffeb56dee1c24.tar.gz
external_webkit-ca9cb53ed1119a3fd98fafa0972ffeb56dee1c24.tar.bz2
Merge WebKit at r62496: Initial merge by git
Change-Id: Ie3da0770eca22a70a632e3571f31cfabc80facb2
Diffstat (limited to 'WebKit/chromium/src/GraphicsContext3D.cpp')
-rw-r--r--WebKit/chromium/src/GraphicsContext3D.cpp75
1 files changed, 69 insertions, 6 deletions
diff --git a/WebKit/chromium/src/GraphicsContext3D.cpp b/WebKit/chromium/src/GraphicsContext3D.cpp
index 0681675..7ba0bce 100644
--- a/WebKit/chromium/src/GraphicsContext3D.cpp
+++ b/WebKit/chromium/src/GraphicsContext3D.cpp
@@ -35,6 +35,8 @@
#include "GraphicsContext3D.h"
#include "CachedImage.h"
+#include "Chrome.h"
+#include "ChromeClientImpl.h"
#include "HTMLCanvasElement.h"
#include "HTMLImageElement.h"
#include "ImageBuffer.h"
@@ -50,10 +52,12 @@
#include "WebGLShader.h"
#include "WebGLTexture.h"
#include "Uint8Array.h"
+#include "WebGLLayerChromium.h"
#include "WebGraphicsContext3D.h"
#include "WebGraphicsContext3DDefaultImpl.h"
#include "WebKit.h"
#include "WebKitClient.h"
+#include "WebViewImpl.h"
#include <stdio.h>
#include <wtf/FastMalloc.h>
@@ -97,7 +101,7 @@ public:
GraphicsContext3DInternal();
~GraphicsContext3DInternal();
- bool initialize(GraphicsContext3D::Attributes attrs);
+ bool initialize(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow);
PlatformGraphicsContext3D platformGraphicsContext3D() const;
Platform3DObject platformTexture() const;
@@ -111,6 +115,11 @@ public:
void beginPaint(WebGLRenderingContext* context);
void endPaint();
+ void prepareTexture();
+
+#if USE(ACCELERATED_COMPOSITING)
+ WebGLLayerChromium* platformLayer() const;
+#endif
bool isGLES2Compliant() const;
//----------------------------------------------------------------------
@@ -165,6 +174,8 @@ public:
bool getActiveAttrib(WebGLProgram* program, unsigned long index, ActiveInfo&);
bool getActiveUniform(WebGLProgram* program, unsigned long index, ActiveInfo&);
+ void getAttachedShaders(WebGLProgram* program, int maxCount, int* count, unsigned int* shaders);
+
int getAttribLocation(WebGLProgram*, const String& name);
void getBooleanv(unsigned long pname, unsigned char* value);
@@ -297,6 +308,9 @@ public:
private:
OwnPtr<WebKit::WebGraphicsContext3D> m_impl;
+#if USE(ACCELERATED_COMPOSITING)
+ RefPtr<WebGLLayerChromium> m_compositingLayer;
+#endif
#if PLATFORM(SKIA)
// If the width and height of the Canvas's backing store don't
// match those that we were given in the most recent call to
@@ -329,7 +343,8 @@ GraphicsContext3DInternal::~GraphicsContext3DInternal()
#endif
}
-bool GraphicsContext3DInternal::initialize(GraphicsContext3D::Attributes attrs)
+bool GraphicsContext3DInternal::initialize(GraphicsContext3D::Attributes attrs,
+ HostWindow* hostWindow)
{
WebKit::WebGraphicsContext3D::Attributes webAttributes;
webAttributes.alpha = attrs.alpha;
@@ -340,23 +355,47 @@ bool GraphicsContext3DInternal::initialize(GraphicsContext3D::Attributes attrs)
WebKit::WebGraphicsContext3D* webContext = WebKit::webKitClient()->createGraphicsContext3D();
if (!webContext)
return false;
- if (!webContext->initialize(webAttributes)) {
+
+ Chrome* chrome = static_cast<Chrome*>(hostWindow);
+ WebKit::ChromeClientImpl* chromeClientImpl = static_cast<WebKit::ChromeClientImpl*>(chrome->client());
+
+ WebKit::WebViewImpl* webView = chromeClientImpl->webView();
+
+ if (!webView)
+ return false;
+ if (!webContext->initialize(webAttributes, webView)) {
delete webContext;
return false;
}
m_impl.set(webContext);
+
+#if USE(ACCELERATED_COMPOSITING)
+ m_compositingLayer = WebGLLayerChromium::create(0);
+#endif
return true;
}
PlatformGraphicsContext3D GraphicsContext3DInternal::platformGraphicsContext3D() const
{
- return 0;
+ return m_impl.get();
}
Platform3DObject GraphicsContext3DInternal::platformTexture() const
{
- return 0;
+ return m_impl->getPlatformTextureId();
+}
+
+void GraphicsContext3DInternal::prepareTexture()
+{
+ m_impl->prepareTexture();
+}
+
+#if USE(ACCELERATED_COMPOSITING)
+WebGLLayerChromium* GraphicsContext3DInternal::platformLayer() const
+{
+ return m_compositingLayer.get();
}
+#endif
void GraphicsContext3DInternal::beginPaint(WebGLRenderingContext* context)
{
@@ -556,6 +595,12 @@ void GraphicsContext3DInternal::name(t1 a1, t2 a2, t3 a3, t4 a4) \
m_impl->name(a1, a2, a3, a4); \
}
+#define DELEGATE_TO_IMPL_4_X1(name, t1, t2, t3, t4) \
+void GraphicsContext3DInternal::name(t1 a1, t2 a2, t3 a3, t4 a4) \
+{ \
+ m_impl->name(EXTRACT(a1), a2, a3, a4); \
+}
+
#define DELEGATE_TO_IMPL_4_X4(name, t1, t2, t3, t4) \
void GraphicsContext3DInternal::name(t1 a1, t2 a2, t3 a3, t4 a4) \
{ \
@@ -734,6 +779,8 @@ bool GraphicsContext3DInternal::getActiveUniform(WebGLProgram* program, unsigned
return true;
}
+DELEGATE_TO_IMPL_4_X1(getAttachedShaders, WebGLProgram*, int, int*, unsigned int*)
+
int GraphicsContext3DInternal::getAttribLocation(WebGLProgram* program, const String& name)
{
return m_impl->getAttribLocation(EXTRACT(program), name.utf8().data());
@@ -1066,7 +1113,7 @@ GraphicsContext3D::~GraphicsContext3D()
PassOwnPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow)
{
GraphicsContext3DInternal* internal = new GraphicsContext3DInternal();
- if (!internal->initialize(attrs)) {
+ if (!internal->initialize(attrs, hostWindow)) {
delete internal;
return 0;
}
@@ -1085,6 +1132,20 @@ Platform3DObject GraphicsContext3D::platformTexture() const
return m_internal->platformTexture();
}
+void GraphicsContext3D::prepareTexture()
+{
+ return m_internal->prepareTexture();
+}
+
+#if USE(ACCELERATED_COMPOSITING)
+PlatformLayer* GraphicsContext3D::platformLayer() const
+{
+ WebGLLayerChromium* webGLLayer = m_internal->platformLayer();
+ webGLLayer->setContext(this);
+ return webGLLayer;
+}
+#endif
+
DELEGATE_TO_INTERNAL(makeContextCurrent)
DELEGATE_TO_INTERNAL_1R(sizeInBytes, int, int)
DELEGATE_TO_INTERNAL_2(reshape, int, int)
@@ -1139,6 +1200,8 @@ DELEGATE_TO_INTERNAL_1(generateMipmap, unsigned long)
DELEGATE_TO_INTERNAL_3R(getActiveAttrib, WebGLProgram*, unsigned long, ActiveInfo&, bool)
DELEGATE_TO_INTERNAL_3R(getActiveUniform, WebGLProgram*, unsigned long, ActiveInfo&, bool)
+DELEGATE_TO_INTERNAL_4(getAttachedShaders, WebGLProgram*, int, int*, unsigned int*)
+
DELEGATE_TO_INTERNAL_2R(getAttribLocation, WebGLProgram*, const String&, int)
DELEGATE_TO_INTERNAL_2(getBooleanv, unsigned long, unsigned char*)