summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/graphics/gpu
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/platform/graphics/gpu')
-rw-r--r--WebCore/platform/graphics/gpu/DrawingBuffer.cpp37
-rw-r--r--WebCore/platform/graphics/gpu/DrawingBuffer.h40
-rw-r--r--WebCore/platform/graphics/gpu/LoopBlinnClassifier.cpp4
-rw-r--r--WebCore/platform/graphics/gpu/LoopBlinnLocalTriangulator.cpp4
-rw-r--r--WebCore/platform/graphics/gpu/LoopBlinnMathUtils.cpp7
-rw-r--r--WebCore/platform/graphics/gpu/LoopBlinnTextureCoords.cpp4
-rw-r--r--WebCore/platform/graphics/gpu/PODInterval.h26
-rw-r--r--WebCore/platform/graphics/gpu/PODIntervalTree.h17
-rw-r--r--WebCore/platform/graphics/gpu/PODRedBlackTree.h17
-rw-r--r--WebCore/platform/graphics/gpu/Shader.cpp5
-rw-r--r--WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp34
-rw-r--r--WebCore/platform/graphics/gpu/SharedGraphicsContext3D.h9
-rw-r--r--WebCore/platform/graphics/gpu/SolidFillShader.cpp5
-rw-r--r--WebCore/platform/graphics/gpu/TexShader.cpp5
-rw-r--r--WebCore/platform/graphics/gpu/Texture.cpp4
-rw-r--r--WebCore/platform/graphics/gpu/Texture.h4
-rw-r--r--WebCore/platform/graphics/gpu/TilingData.cpp5
-rw-r--r--WebCore/platform/graphics/gpu/mac/DrawingBufferMac.mm84
18 files changed, 254 insertions, 57 deletions
diff --git a/WebCore/platform/graphics/gpu/DrawingBuffer.cpp b/WebCore/platform/graphics/gpu/DrawingBuffer.cpp
index dc80954..2dc0517 100644
--- a/WebCore/platform/graphics/gpu/DrawingBuffer.cpp
+++ b/WebCore/platform/graphics/gpu/DrawingBuffer.cpp
@@ -30,31 +30,40 @@
#include "config.h"
-#include "DrawingBuffer.h"
+#if ENABLE(ACCELERATED_2D_CANVAS) || ENABLE(3D_CANVAS)
-#include "GraphicsContext3D.h"
-#include "SharedGraphicsContext3D.h"
+#include "DrawingBuffer.h"
namespace WebCore {
-PassOwnPtr<DrawingBuffer> DrawingBuffer::create(SharedGraphicsContext3D* context, const IntSize& size)
+PassRefPtr<DrawingBuffer> DrawingBuffer::create(GraphicsContext3D* context, const IntSize& size)
{
- unsigned framebuffer = context->createFramebuffer();
- ASSERT(framebuffer);
- if (!framebuffer)
- return 0;
- return adoptPtr(new DrawingBuffer(context, size, framebuffer));
+ RefPtr<DrawingBuffer> drawingBuffer = adoptRef(new DrawingBuffer(context, size));
+ return (drawingBuffer->m_context) ? drawingBuffer.release() : 0;
}
-void DrawingBuffer::bind()
+void DrawingBuffer::clear()
{
- m_context->bindFramebuffer(m_framebuffer);
- m_context->setViewport(m_size);
+ if (!m_context)
+ return;
+
+ m_context->makeContextCurrent();
+ m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo);
+ m_context->deleteFramebuffer(m_fbo);
+ m_fbo = 0;
+
+ m_context.clear();
}
-void DrawingBuffer::setWillPublishCallback(PassOwnPtr<WillPublishCallback> callback)
+void DrawingBuffer::bind()
{
- m_callback = callback;
+ if (!m_context)
+ return;
+
+ m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo);
+ m_context->viewport(0, 0, m_size.width(), m_size.height());
}
} // namespace WebCore
+
+#endif
diff --git a/WebCore/platform/graphics/gpu/DrawingBuffer.h b/WebCore/platform/graphics/gpu/DrawingBuffer.h
index 23e6f4a..75c7f99 100644
--- a/WebCore/platform/graphics/gpu/DrawingBuffer.h
+++ b/WebCore/platform/graphics/gpu/DrawingBuffer.h
@@ -31,30 +31,39 @@
#ifndef DrawingBuffer_h
#define DrawingBuffer_h
+#include "GraphicsContext3D.h"
#include "GraphicsLayer.h"
#include "IntSize.h"
#include <wtf/Noncopyable.h>
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
+#if PLATFORM(MAC)
+#include <wtf/RetainPtr.h>
+#endif
namespace WebCore {
-class SharedGraphicsContext3D;
-
+#if PLATFORM(CHROMIUM)
struct DrawingBufferInternal;
+#endif
// Manages a rendering target (framebuffer + attachment) for a canvas. Can publish its rendering
// results to a PlatformLayer for compositing.
-class DrawingBuffer : public Noncopyable {
+class DrawingBuffer : public RefCounted<DrawingBuffer> {
public:
- static PassOwnPtr<DrawingBuffer> create(SharedGraphicsContext3D*, const IntSize&);
+ friend class GraphicsContext3D;
+
~DrawingBuffer();
void reset(const IntSize&);
void bind();
IntSize size() const { return m_size; }
+ // Clear all resources from this object, as well as context. Called when context is destroyed
+ // to prevent invalid accesses to the resources.
+ void clear();
+
#if USE(ACCELERATED_COMPOSITING)
PlatformLayer* platformLayer();
void publishToPlatformLayer();
@@ -62,21 +71,36 @@ public:
unsigned getRenderingResultsAsTexture();
+#if PLATFORM(CHROMIUM)
class WillPublishCallback : public Noncopyable {
public:
+ virtual ~WillPublishCallback() { }
+
virtual void willPublish() = 0;
};
- void setWillPublishCallback(PassOwnPtr<WillPublishCallback>);
+ void setWillPublishCallback(PassOwnPtr<WillPublishCallback> callback) { m_callback = callback; }
+#endif
+
+ PassRefPtr<GraphicsContext3D> graphicsContext3D() const { return m_context; }
+
private:
- DrawingBuffer(SharedGraphicsContext3D*, const IntSize&, unsigned framebuffer);
+ static PassRefPtr<DrawingBuffer> create(GraphicsContext3D*, const IntSize&);
+
+ DrawingBuffer(GraphicsContext3D*, const IntSize&);
- SharedGraphicsContext3D* m_context;
+ RefPtr<GraphicsContext3D> m_context;
IntSize m_size;
- unsigned m_framebuffer;
+ Platform3DObject m_fbo;
+#if PLATFORM(CHROMIUM)
OwnPtr<WillPublishCallback> m_callback;
OwnPtr<DrawingBufferInternal> m_internal;
+#endif
+
+#if PLATFORM(MAC)
+ RetainPtr<WebGLLayer> m_platformLayer;
+#endif
};
} // namespace WebCore
diff --git a/WebCore/platform/graphics/gpu/LoopBlinnClassifier.cpp b/WebCore/platform/graphics/gpu/LoopBlinnClassifier.cpp
index e43dc37..672b4d7 100644
--- a/WebCore/platform/graphics/gpu/LoopBlinnClassifier.cpp
+++ b/WebCore/platform/graphics/gpu/LoopBlinnClassifier.cpp
@@ -25,6 +25,8 @@
#include "config.h"
+#if ENABLE(ACCELERATED_2D_CANVAS)
+
#include "LoopBlinnClassifier.h"
#include "LoopBlinnMathUtils.h"
@@ -120,3 +122,5 @@ LoopBlinnClassifier::Result LoopBlinnClassifier::classify(const FloatPoint& c0,
}
} // namespace WebCore
+
+#endif
diff --git a/WebCore/platform/graphics/gpu/LoopBlinnLocalTriangulator.cpp b/WebCore/platform/graphics/gpu/LoopBlinnLocalTriangulator.cpp
index 3b73ff6..1517a67 100644
--- a/WebCore/platform/graphics/gpu/LoopBlinnLocalTriangulator.cpp
+++ b/WebCore/platform/graphics/gpu/LoopBlinnLocalTriangulator.cpp
@@ -25,6 +25,8 @@
#include "config.h"
+#if ENABLE(ACCELERATED_2D_CANVAS)
+
#include "LoopBlinnLocalTriangulator.h"
#include "LoopBlinnMathUtils.h"
@@ -273,3 +275,5 @@ bool LoopBlinnLocalTriangulator::isSharedEdge(Vertex* v0, Vertex* v1)
}
} // namespace WebCore
+
+#endif
diff --git a/WebCore/platform/graphics/gpu/LoopBlinnMathUtils.cpp b/WebCore/platform/graphics/gpu/LoopBlinnMathUtils.cpp
index 61ebc9b..5b155a5 100644
--- a/WebCore/platform/graphics/gpu/LoopBlinnMathUtils.cpp
+++ b/WebCore/platform/graphics/gpu/LoopBlinnMathUtils.cpp
@@ -25,12 +25,13 @@
#include "config.h"
+#if ENABLE(ACCELERATED_2D_CANVAS)
+
#include "LoopBlinnMathUtils.h"
#include "FloatPoint.h"
-#include "MathExtras.h"
#include <algorithm>
-#include <string.h> // for memcpy
+#include <wtf/MathExtras.h>
namespace WebCore {
namespace LoopBlinnMathUtils {
@@ -563,3 +564,5 @@ int numXRayCrossingsForCubic(const XRay& xRay, const FloatPoint cubic[4], bool&
} // namespace LoopBlinnMathUtils
} // namespace WebCore
+
+#endif
diff --git a/WebCore/platform/graphics/gpu/LoopBlinnTextureCoords.cpp b/WebCore/platform/graphics/gpu/LoopBlinnTextureCoords.cpp
index ac82637..d272fe1 100644
--- a/WebCore/platform/graphics/gpu/LoopBlinnTextureCoords.cpp
+++ b/WebCore/platform/graphics/gpu/LoopBlinnTextureCoords.cpp
@@ -25,6 +25,8 @@
#include "config.h"
+#if ENABLE(ACCELERATED_2D_CANVAS)
+
#include "LoopBlinnTextureCoords.h"
#include <math.h>
@@ -169,3 +171,5 @@ LoopBlinnTextureCoords::Result LoopBlinnTextureCoords::compute(const LoopBlinnCl
}
} // namespace WebCore
+
+#endif
diff --git a/WebCore/platform/graphics/gpu/PODInterval.h b/WebCore/platform/graphics/gpu/PODInterval.h
index 9df69ba..5c1dcc2 100644
--- a/WebCore/platform/graphics/gpu/PODInterval.h
+++ b/WebCore/platform/graphics/gpu/PODInterval.h
@@ -27,7 +27,7 @@
#define PODInterval_h
#ifndef NDEBUG
-#include "StringBuilder.h"
+#include <wtf/text/StringBuilder.h>
#endif
namespace WebCore {
@@ -57,14 +57,24 @@ namespace WebCore {
// constructor and assignment operator.
//
// In debug mode, printing of intervals and the data they contain is
-// enabled. This requires the following functions to be available:
+// enabled. This requires the following template specializations to be
+// available:
//
-// String valueToString(const T&);
-// String valueToString(const UserData&);
+// template<> struct WebCore::ValueToString<T> {
+// static String string(const T& t);
+// };
+// template<> struct WebCore::ValueToString<UserData> {
+// static String string(const UserData& t);
+// };
//
// Note that this class requires a copy constructor and assignment
// operator in order to be stored in the red-black tree.
+#ifndef NDEBUG
+template<class T>
+struct ValueToString;
+#endif
+
template<class T, class UserData = void*>
class PODInterval {
public:
@@ -131,13 +141,13 @@ public:
{
StringBuilder builder;
builder.append("[PODInterval (");
- builder.append(valueToString(low()));
+ builder.append(ValueToString<T>::string(low()));
builder.append(", ");
- builder.append(valueToString(high()));
+ builder.append(ValueToString<T>::string(high()));
builder.append("), data=");
- builder.append(valueToString(data()));
+ builder.append(ValueToString<UserData>::string(data()));
builder.append(", maxHigh=");
- builder.append(valueToString(maxHigh()));
+ builder.append(ValueToString<T>::string(maxHigh()));
builder.append("]");
return builder.toString();
}
diff --git a/WebCore/platform/graphics/gpu/PODIntervalTree.h b/WebCore/platform/graphics/gpu/PODIntervalTree.h
index c0a86aa..320ce60 100644
--- a/WebCore/platform/graphics/gpu/PODIntervalTree.h
+++ b/WebCore/platform/graphics/gpu/PODIntervalTree.h
@@ -35,6 +35,11 @@
namespace WebCore {
+#ifndef NDEBUG
+template<class T>
+struct ValueToString;
+#endif
+
// An interval tree, which is a form of augmented red-black tree. It
// supports efficient (O(lg n)) insertion, removal and querying of
// intervals in the tree.
@@ -191,7 +196,7 @@ private:
localMaxValue = node->data().high();
if (!(localMaxValue == node->data().maxHigh())) {
#ifndef NDEBUG
- String localMaxValueString = valueToString(localMaxValue);
+ String localMaxValueString = ValueToString<T>::string(localMaxValue);
LOG_ERROR("PODIntervalTree verification failed at node 0x%p: localMaxValue=%s and data=%s",
node, localMaxValueString.utf8().data(), node->data().toString().utf8().data());
#endif
@@ -206,10 +211,12 @@ private:
#ifndef NDEBUG
// Support for printing PODIntervals at the PODRedBlackTree level.
template<class T, class UserData>
-String valueToString(const PODInterval<T, UserData>& interval)
-{
- return interval.toString();
-}
+struct ValueToString<PODInterval<T, UserData> > {
+ static String string(const PODInterval<T, UserData>& interval)
+ {
+ return interval.toString();
+ }
+};
#endif
} // namespace WebCore
diff --git a/WebCore/platform/graphics/gpu/PODRedBlackTree.h b/WebCore/platform/graphics/gpu/PODRedBlackTree.h
index 9b02037..6d5954c 100644
--- a/WebCore/platform/graphics/gpu/PODRedBlackTree.h
+++ b/WebCore/platform/graphics/gpu/PODRedBlackTree.h
@@ -42,9 +42,11 @@
// the "<" and "==" operators.
//
// In debug mode, printing of the data contained in the tree is
-// enabled. This requires the following function to be available:
+// enabled. This requires the template specialization to be available:
//
-// String valueToString(const T&);
+// template<> struct WebCore::ValueToString<T> {
+// static String string(const T& t);
+// };
//
// Note that when complex types are stored in this red/black tree, it
// is possible that single invocations of the "<" and "==" operators
@@ -76,13 +78,18 @@
#include <wtf/RefPtr.h>
#ifndef NDEBUG
#include "Logging.h"
-#include "PlatformString.h"
-#include "StringBuilder.h"
#include <wtf/text/CString.h>
+#include <wtf/text/StringBuilder.h>
+#include <wtf/text/WTFString.h>
#endif
namespace WebCore {
+#ifndef NDEBUG
+template<class T>
+struct ValueToString;
+#endif
+
template<class T>
class PODRedBlackTree {
public:
@@ -723,7 +730,7 @@ private:
builder.append("-");
if (node) {
builder.append(" ");
- builder.append(valueToString(node->data()));
+ builder.append(ValueToString<T>::string(node->data()));
builder.append((node->color() == Black) ? " (black)" : " (red)");
}
LOG_ERROR("%s", builder.toString().ascii().data());
diff --git a/WebCore/platform/graphics/gpu/Shader.cpp b/WebCore/platform/graphics/gpu/Shader.cpp
index 59c50a7..8983adc 100644
--- a/WebCore/platform/graphics/gpu/Shader.cpp
+++ b/WebCore/platform/graphics/gpu/Shader.cpp
@@ -29,6 +29,9 @@
*/
#include "config.h"
+
+#if ENABLE(ACCELERATED_2D_CANVAS)
+
#include "Shader.h"
#include "AffineTransform.h"
@@ -109,3 +112,5 @@ Shader::~Shader()
}
}
+
+#endif
diff --git a/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp b/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp
index 7629735..87a0b69 100644
--- a/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp
+++ b/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp
@@ -30,6 +30,8 @@
#include "config.h"
+#if ENABLE(ACCELERATED_2D_CANVAS)
+
#include "SharedGraphicsContext3D.h"
#include "AffineTransform.h"
@@ -47,16 +49,26 @@
namespace WebCore {
// static
-PassRefPtr<SharedGraphicsContext3D> SharedGraphicsContext3D::create(PassOwnPtr<GraphicsContext3D> context)
-{
- return adoptRef(new SharedGraphicsContext3D(context));
-}
-
-SharedGraphicsContext3D::SharedGraphicsContext3D(PassOwnPtr<GraphicsContext3D> context)
+PassRefPtr<SharedGraphicsContext3D> SharedGraphicsContext3D::create(HostWindow* hostWindow)
+{
+ GraphicsContext3D::Attributes attr;
+ RefPtr<GraphicsContext3D> context = GraphicsContext3D::create(attr, hostWindow);
+ if (!context)
+ return 0;
+ OwnPtr<SolidFillShader> solidFillShader = SolidFillShader::create(context.get());
+ if (!solidFillShader)
+ return 0;
+ OwnPtr<TexShader> texShader = TexShader::create(context.get());
+ if (!texShader)
+ return 0;
+ return adoptRef(new SharedGraphicsContext3D(context.release(), solidFillShader.release(), texShader.release()));
+}
+
+SharedGraphicsContext3D::SharedGraphicsContext3D(PassRefPtr<GraphicsContext3D> context, PassOwnPtr<SolidFillShader> solidFillShader, PassOwnPtr<TexShader> texShader)
: m_context(context)
, m_quadVertices(0)
- , m_solidFillShader(SolidFillShader::create(m_context.get()))
- , m_texShader(TexShader::create(m_context.get()))
+ , m_solidFillShader(solidFillShader)
+ , m_texShader(texShader)
{
allContexts()->add(this);
}
@@ -215,8 +227,8 @@ void SharedGraphicsContext3D::removeTexturesFor(NativeImagePtr ptr)
// static
HashSet<SharedGraphicsContext3D*>* SharedGraphicsContext3D::allContexts()
{
- static OwnPtr<HashSet<SharedGraphicsContext3D*> > set(new HashSet<SharedGraphicsContext3D*>);
- return set.get();
+ DEFINE_STATIC_LOCAL(HashSet<SharedGraphicsContext3D*>, allContextsSet, ());
+ return &allContextsSet;
}
@@ -334,3 +346,5 @@ bool SharedGraphicsContext3D::paintsIntoCanvasBuffer() const
}
} // namespace WebCore
+
+#endif
diff --git a/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.h b/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.h
index 3ba3c52..05008c2 100644
--- a/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.h
+++ b/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.h
@@ -47,6 +47,7 @@ class AffineTransform;
class Color;
class GraphicsContext3D;
class FloatRect;
+class HostWindow;
class IntSize;
class SolidFillShader;
class TexShader;
@@ -55,7 +56,7 @@ typedef HashMap<NativeImagePtr, RefPtr<Texture> > TextureHashMap;
class SharedGraphicsContext3D : public RefCounted<SharedGraphicsContext3D> {
public:
- static PassRefPtr<SharedGraphicsContext3D> create(PassOwnPtr<GraphicsContext3D>);
+ static PassRefPtr<SharedGraphicsContext3D> create(HostWindow*);
~SharedGraphicsContext3D();
// Functions that delegate directly to GraphicsContext3D, with caching
@@ -117,14 +118,16 @@ public:
// the texture.
PassRefPtr<Texture> createTexture(Texture::Format, int width, int height);
+ GraphicsContext3D* graphicsContext3D() const { return m_context.get(); }
+
private:
- explicit SharedGraphicsContext3D(PassOwnPtr<GraphicsContext3D> context);
+ SharedGraphicsContext3D(PassRefPtr<GraphicsContext3D>, PassOwnPtr<SolidFillShader>, PassOwnPtr<TexShader>);
// Used to implement removeTexturesFor(), see the comment above.
static HashSet<SharedGraphicsContext3D*>* allContexts();
void removeTextureFor(NativeImagePtr);
- OwnPtr<GraphicsContext3D> m_context;
+ RefPtr<GraphicsContext3D> m_context;
unsigned m_quadVertices;
diff --git a/WebCore/platform/graphics/gpu/SolidFillShader.cpp b/WebCore/platform/graphics/gpu/SolidFillShader.cpp
index ff1b1fa..86079be 100644
--- a/WebCore/platform/graphics/gpu/SolidFillShader.cpp
+++ b/WebCore/platform/graphics/gpu/SolidFillShader.cpp
@@ -29,6 +29,9 @@
*/
#include "config.h"
+
+#if ENABLE(ACCELERATED_2D_CANVAS)
+
#include "SolidFillShader.h"
#include "Color.h"
@@ -86,3 +89,5 @@ void SolidFillShader::use(const AffineTransform& transform, const Color& color)
}
}
+
+#endif
diff --git a/WebCore/platform/graphics/gpu/TexShader.cpp b/WebCore/platform/graphics/gpu/TexShader.cpp
index 01f4306..d7ffa17 100644
--- a/WebCore/platform/graphics/gpu/TexShader.cpp
+++ b/WebCore/platform/graphics/gpu/TexShader.cpp
@@ -29,6 +29,9 @@
*/
#include "config.h"
+
+#if ENABLE(ACCELERATED_2D_CANVAS)
+
#include "TexShader.h"
#include "GraphicsContext3D.h"
@@ -93,3 +96,5 @@ void TexShader::use(const AffineTransform& transform, const AffineTransform& tex
}
}
+
+#endif
diff --git a/WebCore/platform/graphics/gpu/Texture.cpp b/WebCore/platform/graphics/gpu/Texture.cpp
index 6023fe9..74807dc 100644
--- a/WebCore/platform/graphics/gpu/Texture.cpp
+++ b/WebCore/platform/graphics/gpu/Texture.cpp
@@ -30,6 +30,8 @@
#include "config.h"
+#if ENABLE(ACCELERATED_2D_CANVAS)
+
#include "Texture.h"
#include "FloatRect.h"
@@ -206,3 +208,5 @@ void Texture::bindTile(int tile)
}
}
+
+#endif
diff --git a/WebCore/platform/graphics/gpu/Texture.h b/WebCore/platform/graphics/gpu/Texture.h
index eda475e..92b6d0a 100644
--- a/WebCore/platform/graphics/gpu/Texture.h
+++ b/WebCore/platform/graphics/gpu/Texture.h
@@ -31,11 +31,11 @@
#ifndef Texture_h
#define Texture_h
-#include "RefCounted.h"
-#include "RefPtr.h"
#include "TilingData.h"
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
#include <wtf/Vector.h>
namespace WebCore {
diff --git a/WebCore/platform/graphics/gpu/TilingData.cpp b/WebCore/platform/graphics/gpu/TilingData.cpp
index 4da242b..a98add7 100644
--- a/WebCore/platform/graphics/gpu/TilingData.cpp
+++ b/WebCore/platform/graphics/gpu/TilingData.cpp
@@ -29,6 +29,9 @@
*/
#include "config.h"
+
+#if ENABLE(ACCELERATED_2D_CANVAS)
+
#include "TilingData.h"
#include "FloatRect.h"
@@ -220,3 +223,5 @@ void TilingData::intersectDrawQuad(const FloatRect& srcRect, const FloatRect& ds
}
}
+
+#endif
diff --git a/WebCore/platform/graphics/gpu/mac/DrawingBufferMac.mm b/WebCore/platform/graphics/gpu/mac/DrawingBufferMac.mm
new file mode 100644
index 0000000..7a8c501
--- /dev/null
+++ b/WebCore/platform/graphics/gpu/mac/DrawingBufferMac.mm
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(ACCELERATED_2D_CANVAS) || ENABLE(3D_CANVAS)
+
+#include "DrawingBuffer.h"
+
+#include "WebGLLayer.h"
+
+#import "BlockExceptions.h"
+
+namespace WebCore {
+
+DrawingBuffer::DrawingBuffer(GraphicsContext3D* context, const IntSize& size)
+ : m_context(context)
+ , m_size(size)
+ , m_fbo(context->createFramebuffer())
+{
+ ASSERT(m_fbo);
+ if (!m_fbo) {
+ clear();
+ return;
+ }
+
+ // Create the WebGLLayer
+ BEGIN_BLOCK_OBJC_EXCEPTIONS
+ m_platformLayer.adoptNS([[WebGLLayer alloc] initWithGraphicsContext3D:m_context.get()]);
+#ifndef NDEBUG
+ [m_platformLayer.get() setName:@"DrawingBuffer Layer"];
+#endif
+ END_BLOCK_OBJC_EXCEPTIONS
+}
+
+DrawingBuffer::~DrawingBuffer()
+{
+ clear();
+}
+
+void DrawingBuffer::reset(const IntSize& newSize)
+{
+ if (!m_context)
+ return;
+
+ if (m_size == newSize)
+ return;
+ m_size = newSize;
+
+ m_context->texImage2D(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, m_size.width(), m_size.height(), 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, 0);
+}
+
+#if USE(ACCELERATED_COMPOSITING)
+PlatformLayer* DrawingBuffer::platformLayer()
+{
+ return m_platformLayer.get();
+}
+#endif
+
+}
+
+#endif