Diff
Modified: trunk/Source/WebCore/ChangeLog (122179 => 122180)
--- trunk/Source/WebCore/ChangeLog 2012-07-10 01:39:55 UTC (rev 122179)
+++ trunk/Source/WebCore/ChangeLog 2012-07-10 01:43:31 UTC (rev 122180)
@@ -1,3 +1,48 @@
+2012-07-09 Dana Jansens <[email protected]>
+
+ [chromium] Create CCScopedTexture class for creating/freeing textures
+ https://bugs.webkit.org/show_bug.cgi?id=89485
+
+ Reviewed by Adrienne Walker.
+
+ This class provides a standard way to create texture ids in a way that
+ ensures they will be freed later.
+
+ Also includes a CCTexture base class that holds textureId, size, and
+ format together in a struct that can be used in place of storing an
+ unsigned textureId in other classes.
+
+ Unit tests: CCScopedTexureTest.NewScopedTexture
+ CCScopedTexureTest.CreateScopedTexture
+ CCScopedTexureTest.ScopedTextureIsDeleted
+ CCScopedTexureTest.LoseScopedTexture
+
+ * WebCore.gypi:
+ * platform/graphics/chromium/cc/CCScopedTexture.cpp: Added.
+ (WebCore):
+ (WebCore::CCScopedTexture::CCScopedTexture):
+ (WebCore::CCScopedTexture::~CCScopedTexture):
+ (WebCore::CCScopedTexture::allocate):
+ (WebCore::CCScopedTexture::free):
+ (WebCore::CCScopedTexture::leak):
+ * platform/graphics/chromium/cc/CCScopedTexture.h: Added.
+ (WebCore):
+ (CCScopedTexture):
+ (WebCore::CCScopedTexture::create):
+ * platform/graphics/chromium/cc/CCTexture.cpp: Added.
+ (WebCore):
+ (WebCore::CCTexture::setDimensions):
+ (WebCore::CCTexture::bytes):
+ (WebCore::CCTexture::memorySizeBytes):
+ * platform/graphics/chromium/cc/CCTexture.h: Added.
+ (WebCore):
+ (CCTexture):
+ (WebCore::CCTexture::CCTexture):
+ (WebCore::CCTexture::id):
+ (WebCore::CCTexture::size):
+ (WebCore::CCTexture::format):
+ (WebCore::CCTexture::setId):
+
2012-07-09 Joshua Bell <[email protected]>
IndexedDB: deleteDatabase fails if transaction running in other database
Modified: trunk/Source/WebCore/WebCore.gypi (122179 => 122180)
--- trunk/Source/WebCore/WebCore.gypi 2012-07-10 01:39:55 UTC (rev 122179)
+++ trunk/Source/WebCore/WebCore.gypi 2012-07-10 01:43:31 UTC (rev 122180)
@@ -8361,6 +8361,8 @@
'platform/graphics/chromium/cc/CCScheduler.h',
'platform/graphics/chromium/cc/CCSchedulerStateMachine.cpp',
'platform/graphics/chromium/cc/CCSchedulerStateMachine.h',
+ 'platform/graphics/chromium/cc/CCScopedTexture.cpp',
+ 'platform/graphics/chromium/cc/CCScopedTexture.h',
'platform/graphics/chromium/cc/CCScopedThreadProxy.h',
'platform/graphics/chromium/cc/CCScrollbarLayerImpl.cpp',
'platform/graphics/chromium/cc/CCScrollbarLayerImpl.h',
@@ -8376,6 +8378,8 @@
'platform/graphics/chromium/cc/CCSolidColorLayerImpl.h',
'platform/graphics/chromium/cc/CCStreamVideoDrawQuad.cpp',
'platform/graphics/chromium/cc/CCStreamVideoDrawQuad.h',
+ 'platform/graphics/chromium/cc/CCTexture.cpp',
+ 'platform/graphics/chromium/cc/CCTexture.h',
'platform/graphics/chromium/cc/CCTextureDrawQuad.cpp',
'platform/graphics/chromium/cc/CCTextureDrawQuad.h',
'platform/graphics/chromium/cc/CCTextureLayerImpl.cpp',
Added: trunk/Source/WebCore/platform/graphics/chromium/cc/CCScopedTexture.cpp (0 => 122180)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCScopedTexture.cpp (rev 0)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCScopedTexture.cpp 2012-07-10 01:43:31 UTC (rev 122180)
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2012 Google 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 AND ITS CONTRIBUTORS "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 OR ITS 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"
+
+#include "cc/CCScopedTexture.h"
+
+#include "TextureManager.h" // For TextureAllocator
+
+namespace WebCore {
+
+CCScopedTexture::CCScopedTexture(TextureAllocator* allocator)
+ : m_allocator(allocator)
+{
+ ASSERT(m_allocator);
+}
+
+CCScopedTexture::~CCScopedTexture()
+{
+ free();
+}
+
+bool CCScopedTexture::allocate(const IntSize& size, GC3Denum format)
+{
+ ASSERT(!id());
+ ASSERT(!size.isEmpty());
+
+ setDimensions(size, format);
+ setId(m_allocator->createTexture(size, format));
+
+#if !ASSERT_DISABLED
+ m_allocateThreadIdentifier = WTF::currentThread();
+#endif
+
+ return id();
+}
+
+void CCScopedTexture::free()
+{
+ if (id()) {
+ ASSERT(m_allocateThreadIdentifier == WTF::currentThread());
+ m_allocator->deleteTexture(id(), size(), format());
+ }
+ setId(0);
+}
+
+void CCScopedTexture::leak()
+{
+ setId(0);
+}
+
+}
Property changes on: trunk/Source/WebCore/platform/graphics/chromium/cc/CCScopedTexture.cpp
___________________________________________________________________
Added: svn:eol-style
Added: trunk/Source/WebCore/platform/graphics/chromium/cc/CCScopedTexture.h (0 => 122180)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCScopedTexture.h (rev 0)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCScopedTexture.h 2012-07-10 01:43:31 UTC (rev 122180)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2012 Google 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 AND ITS CONTRIBUTORS "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 OR ITS 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.
+ */
+
+#ifndef CCScopedTexture_h
+#define CCScopedTexture_h
+
+#include "cc/CCTexture.h"
+
+#if !ASSERT_DISABLED
+#include <wtf/MainThread.h>
+#endif
+
+namespace WebCore {
+
+class TextureAllocator;
+
+class CCScopedTexture : protected CCTexture {
+ WTF_MAKE_NONCOPYABLE(CCScopedTexture);
+public:
+ static PassOwnPtr<CCScopedTexture> create(TextureAllocator* allocator) { return adoptPtr(new CCScopedTexture(allocator)); }
+ virtual ~CCScopedTexture();
+
+ using CCTexture::id;
+ using CCTexture::size;
+ using CCTexture::format;
+ using CCTexture::bytes;
+
+ bool allocate(const IntSize&, GC3Denum format);
+ void free();
+ void leak();
+
+protected:
+ explicit CCScopedTexture(TextureAllocator*);
+
+private:
+ TextureAllocator* m_allocator;
+
+#if !ASSERT_DISABLED
+ ThreadIdentifier m_allocateThreadIdentifier;
+#endif
+};
+
+}
+
+#endif
Property changes on: trunk/Source/WebCore/platform/graphics/chromium/cc/CCScopedTexture.h
___________________________________________________________________
Added: svn:eol-style
Added: trunk/Source/WebCore/platform/graphics/chromium/cc/CCTexture.cpp (0 => 122180)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCTexture.cpp (rev 0)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCTexture.cpp 2012-07-10 01:43:31 UTC (rev 122180)
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2012 Google 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 AND ITS CONTRIBUTORS "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 OR ITS 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"
+
+#include "cc/CCTexture.h"
+
+namespace WebCore {
+
+void CCTexture::setDimensions(const IntSize& size, GC3Denum format)
+{
+ m_size = size;
+ m_format = format;
+}
+
+size_t CCTexture::bytes() const
+{
+ if (m_size.isEmpty())
+ return 0u;
+
+ return memorySizeBytes(m_size, m_format);
+}
+
+size_t CCTexture::memorySizeBytes(const IntSize& size, GC3Denum format)
+{
+ unsigned int componentsPerPixel;
+ unsigned int bytesPerComponent;
+ if (!GraphicsContext3D::computeFormatAndTypeParameters(format, GraphicsContext3D::UNSIGNED_BYTE, &componentsPerPixel, &bytesPerComponent)) {
+ ASSERT_NOT_REACHED();
+ return 0u;
+ }
+ return componentsPerPixel * bytesPerComponent * size.width() * size.height();
+}
+
+}
Property changes on: trunk/Source/WebCore/platform/graphics/chromium/cc/CCTexture.cpp
___________________________________________________________________
Added: svn:eol-style
Added: trunk/Source/WebCore/platform/graphics/chromium/cc/CCTexture.h (0 => 122180)
--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCTexture.h (rev 0)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCTexture.h 2012-07-10 01:43:31 UTC (rev 122180)
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2012 Google 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 AND ITS CONTRIBUTORS "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 OR ITS 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.
+ */
+
+#ifndef CCTexture_h
+#define CCTexture_h
+
+#include "GraphicsContext3D.h"
+#include "IntSize.h"
+#include "cc/CCTexture.h"
+
+namespace WebCore {
+
+class CCTexture {
+public:
+ CCTexture() : m_id(0) { }
+
+ unsigned id() const { return m_id; }
+ const IntSize& size() const { return m_size; }
+ GC3Denum format() const { return m_format; }
+
+ void setId(unsigned id) { m_id = id; }
+ void setDimensions(const IntSize&, GC3Denum format);
+
+ size_t bytes() const;
+
+ static size_t memorySizeBytes(const IntSize&, GC3Denum format);
+
+private:
+ unsigned m_id;
+ IntSize m_size;
+ GC3Denum m_format;
+};
+
+}
+
+#endif
Property changes on: trunk/Source/WebCore/platform/graphics/chromium/cc/CCTexture.h
___________________________________________________________________
Added: svn:eol-style
Modified: trunk/Source/WebKit/chromium/ChangeLog (122179 => 122180)
--- trunk/Source/WebKit/chromium/ChangeLog 2012-07-10 01:39:55 UTC (rev 122179)
+++ trunk/Source/WebKit/chromium/ChangeLog 2012-07-10 01:43:31 UTC (rev 122180)
@@ -1,3 +1,18 @@
+2012-07-09 Dana Jansens <[email protected]>
+
+ [chromium] Create CCScopedTexture class for creating/freeing textures
+ https://bugs.webkit.org/show_bug.cgi?id=89485
+
+ Reviewed by Adrienne Walker.
+
+ * WebKit.gypi:
+ * tests/CCScopedTextureTest.cpp: Added.
+ (WebKitTests):
+ (WebKitTests::TEST):
+ (TrackingTextureAllocator):
+ (WebKitTests::TrackingTextureAllocator::TrackingTextureAllocator):
+ (WebKitTests::TrackingTextureAllocator::numTextures):
+
2012-07-09 Joshua Bell <[email protected]>
IndexedDB: Remove obsolete accessor plumbing
Modified: trunk/Source/WebKit/chromium/WebKit.gypi (122179 => 122180)
--- trunk/Source/WebKit/chromium/WebKit.gypi 2012-07-10 01:39:55 UTC (rev 122179)
+++ trunk/Source/WebKit/chromium/WebKit.gypi 2012-07-10 01:43:31 UTC (rev 122180)
@@ -86,6 +86,7 @@
'tests/CCSchedulerStateMachineTest.cpp',
'tests/CCSchedulerTestCommon.h',
'tests/CCSchedulerTest.cpp',
+ 'tests/CCScopedTextureTest.cpp',
'tests/CCSolidColorLayerImplTest.cpp',
'tests/CCTestCommon.h',
'tests/CCTiledLayerImplTest.cpp',
Added: trunk/Source/WebKit/chromium/tests/CCScopedTextureTest.cpp (0 => 122180)
--- trunk/Source/WebKit/chromium/tests/CCScopedTextureTest.cpp (rev 0)
+++ trunk/Source/WebKit/chromium/tests/CCScopedTextureTest.cpp 2012-07-10 01:43:31 UTC (rev 122180)
@@ -0,0 +1,159 @@
+/*
+ * Copyright (C) 2012 Google 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. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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"
+
+#include "cc/CCScopedTexture.h"
+
+#include "CCTiledLayerTestCommon.h"
+#include "GraphicsContext3D.h"
+
+#include <gtest/gtest.h>
+
+using namespace WebCore;
+using namespace WebKit;
+using namespace WebKitTests;
+
+namespace {
+
+TEST(CCScopedTextureTest, NewScopedTexture)
+{
+ FakeTextureAllocator allocator;
+ OwnPtr<CCScopedTexture> texture = CCScopedTexture::create(&allocator);
+
+ // New scoped textures do not hold a texture yet.
+ EXPECT_EQ(0u, texture->id());
+
+ // New scoped textures do not have a size yet.
+ EXPECT_EQ(IntSize(), texture->size());
+ EXPECT_EQ(0u, texture->bytes());
+}
+
+TEST(CCScopedTextureTest, CreateScopedTexture)
+{
+ FakeTextureAllocator allocator;
+ OwnPtr<CCScopedTexture> texture = CCScopedTexture::create(&allocator);
+ texture->allocate(IntSize(30, 30), GraphicsContext3D::RGBA);
+
+ // The texture has an allocated byte-size now.
+ size_t expectedBytes = 30 * 30 * 4;
+ EXPECT_EQ(expectedBytes, texture->bytes());
+
+ EXPECT_LT(0u, texture->id());
+ EXPECT_EQ(GraphicsContext3D::RGBA, texture->format());
+ EXPECT_EQ(IntSize(30, 30), texture->size());
+}
+
+// Fake TextureAllocator that tracks the number of textures in use.
+class TrackingTextureAllocator : public TextureAllocator {
+public:
+ TrackingTextureAllocator()
+ : m_nextTextureId(1)
+ , m_numTextures(0)
+ { }
+
+ virtual unsigned createTexture(const WebCore::IntSize&, GC3Denum) OVERRIDE
+ {
+ unsigned id = m_nextTextureId;
+ ++m_nextTextureId;
+
+ m_textures.set(id, true);
+ ++m_numTextures;
+ return id;
+ }
+
+ virtual void deleteTexture(unsigned id, const WebCore::IntSize&, GC3Denum) OVERRIDE
+ {
+ if (!m_textures.get(id))
+ return;
+
+ m_textures.set(id, false);
+ --m_numTextures;
+ }
+
+ virtual void deleteAllTextures() OVERRIDE
+ {
+ m_textures.clear();
+ m_numTextures = 0;
+ }
+
+ unsigned numTextures() const { return m_numTextures; }
+
+private:
+ unsigned m_nextTextureId;
+ HashMap<unsigned, bool> m_textures;
+ unsigned m_numTextures;
+};
+
+TEST(CCScopedTextureTest, ScopedTextureIsDeleted)
+{
+ TrackingTextureAllocator allocator;
+
+ {
+ OwnPtr<CCScopedTexture> texture = CCScopedTexture::create(&allocator);
+
+ EXPECT_EQ(0u, allocator.numTextures());
+ texture->allocate(IntSize(30, 30), GraphicsContext3D::RGBA);
+ EXPECT_LT(0u, texture->id());
+ EXPECT_EQ(1u, allocator.numTextures());
+ }
+
+ EXPECT_EQ(0u, allocator.numTextures());
+
+ {
+ OwnPtr<CCScopedTexture> texture = CCScopedTexture::create(&allocator);
+ EXPECT_EQ(0u, allocator.numTextures());
+ texture->allocate(IntSize(30, 30), GraphicsContext3D::RGBA);
+ EXPECT_LT(0u, texture->id());
+ EXPECT_EQ(1u, allocator.numTextures());
+ texture->free();
+ EXPECT_EQ(0u, allocator.numTextures());
+ }
+}
+
+TEST(CCScopedTextureTest, LeakScopedTexture)
+{
+ TrackingTextureAllocator allocator;
+
+ {
+ OwnPtr<CCScopedTexture> texture = CCScopedTexture::create(&allocator);
+
+ EXPECT_EQ(0u, allocator.numTextures());
+ texture->allocate(IntSize(30, 30), GraphicsContext3D::RGBA);
+ EXPECT_LT(0u, texture->id());
+ EXPECT_EQ(1u, allocator.numTextures());
+
+ texture->leak();
+ EXPECT_EQ(0u, texture->id());
+ EXPECT_EQ(1u, allocator.numTextures());
+
+ texture->free();
+ EXPECT_EQ(0u, texture->id());
+ EXPECT_EQ(1u, allocator.numTextures());
+ }
+
+ EXPECT_EQ(1u, allocator.numTextures());
+}
+
+}
Property changes on: trunk/Source/WebKit/chromium/tests/CCScopedTextureTest.cpp
___________________________________________________________________
Added: svn:eol-style