#include "cc/resources/single_release_callback.h"
#include "cc/test/fake_output_surface.h"
#include "cc/test/fake_output_surface_client.h"
+#include "cc/test/test_gpu_memory_buffer_manager.h"
#include "cc/test/test_shared_bitmap_manager.h"
#include "cc/test/test_texture.h"
#include "cc/test/test_web_graphics_context_3d.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/khronos/GLES2/gl2.h"
#include "third_party/khronos/GLES2/gl2ext.h"
-#include "ui/gfx/rect.h"
+#include "ui/gfx/geometry/rect.h"
+#include "ui/gfx/gpu_memory_buffer.h"
using testing::Mock;
using testing::NiceMock;
// Force all textures to be consecutive numbers starting at "1",
// so we easily can test for them.
- virtual GLuint NextTextureId() OVERRIDE {
+ virtual GLuint NextTextureId() override {
base::AutoLock lock(namespace_->lock);
return namespace_->next_texture_id++;
}
- virtual void RetireTextureId(GLuint) OVERRIDE {}
+ virtual void RetireTextureId(GLuint) override {}
};
// Shared data between multiple ResourceProviderContext. This contains mailbox
uint32 next_sync_point_;
unsigned next_mailbox_;
- typedef base::hash_map<unsigned, scoped_refptr<TestTexture> > TextureMap;
+ typedef base::hash_map<unsigned, scoped_refptr<TestTexture>> TextureMap;
TextureMap textures_;
base::hash_map<unsigned, uint32> sync_point_for_mailbox_;
};
return make_scoped_ptr(new ResourceProviderContext(shared_data));
}
- virtual GLuint insertSyncPoint() OVERRIDE {
+ GLuint insertSyncPoint() override {
uint32 sync_point = shared_data_->InsertSyncPoint();
// Commit the produceTextureCHROMIUM calls at this point, so that
// they're associated with the sync point.
return sync_point;
}
- virtual void waitSyncPoint(GLuint sync_point) OVERRIDE {
+ void waitSyncPoint(GLuint sync_point) override {
last_waited_sync_point_ = std::max(sync_point, last_waited_sync_point_);
}
unsigned last_waited_sync_point() const { return last_waited_sync_point_; }
- virtual void texStorage2DEXT(GLenum target,
- GLint levels,
- GLuint internalformat,
- GLint width,
- GLint height) OVERRIDE {
+ void texStorage2DEXT(GLenum target,
+ GLint levels,
+ GLuint internalformat,
+ GLint width,
+ GLint height) override {
CheckTextureIsBound(target);
ASSERT_EQ(static_cast<unsigned>(GL_TEXTURE_2D), target);
ASSERT_EQ(1, levels);
AllocateTexture(gfx::Size(width, height), format);
}
- virtual void texImage2D(GLenum target,
- GLint level,
- GLenum internalformat,
- GLsizei width,
- GLsizei height,
- GLint border,
- GLenum format,
- GLenum type,
- const void* pixels) OVERRIDE {
+ void texImage2D(GLenum target,
+ GLint level,
+ GLenum internalformat,
+ GLsizei width,
+ GLsizei height,
+ GLint border,
+ GLenum format,
+ GLenum type,
+ const void* pixels) override {
CheckTextureIsBound(target);
ASSERT_EQ(static_cast<unsigned>(GL_TEXTURE_2D), target);
ASSERT_FALSE(level);
SetPixels(0, 0, width, height, pixels);
}
- virtual void texSubImage2D(GLenum target,
- GLint level,
- GLint xoffset,
- GLint yoffset,
- GLsizei width,
- GLsizei height,
- GLenum format,
- GLenum type,
- const void* pixels) OVERRIDE {
+ void texSubImage2D(GLenum target,
+ GLint level,
+ GLint xoffset,
+ GLint yoffset,
+ GLsizei width,
+ GLsizei height,
+ GLenum format,
+ GLenum type,
+ const void* pixels) override {
CheckTextureIsBound(target);
ASSERT_EQ(static_cast<unsigned>(GL_TEXTURE_2D), target);
ASSERT_FALSE(level);
SetPixels(xoffset, yoffset, width, height, pixels);
}
- virtual void genMailboxCHROMIUM(GLbyte* mailbox) OVERRIDE {
+ void genMailboxCHROMIUM(GLbyte* mailbox) override {
return shared_data_->GenMailbox(mailbox);
}
- virtual void produceTextureCHROMIUM(GLenum target,
- const GLbyte* mailbox) OVERRIDE {
+ void produceTextureCHROMIUM(GLenum target, const GLbyte* mailbox) override {
CheckTextureIsBound(target);
// Delay moving the texture into the mailbox until the next
pending_produce_textures_.push_back(pending.Pass());
}
- virtual void consumeTextureCHROMIUM(GLenum target,
- const GLbyte* mailbox) OVERRIDE {
+ void consumeTextureCHROMIUM(GLenum target, const GLbyte* mailbox) override {
CheckTextureIsBound(target);
base::AutoLock lock_for_texture_access(namespace_->lock);
scoped_refptr<TestTexture> texture =
context3d_ = context3d.get();
scoped_refptr<TestContextProvider> context_provider =
- TestContextProvider::Create(
- context3d.PassAs<TestWebGraphicsContext3D>());
+ TestContextProvider::Create(context3d.Pass());
output_surface_ = FakeOutputSurface::Create3d(context_provider);
scoped_ptr<ResourceProviderContext> child_context_owned =
ResourceProviderContext::Create(shared_data_.get());
child_context_ = child_context_owned.get();
- child_output_surface_ = FakeOutputSurface::Create3d(
- child_context_owned.PassAs<TestWebGraphicsContext3D>());
+ child_output_surface_ =
+ FakeOutputSurface::Create3d(child_context_owned.Pass());
break;
}
case ResourceProvider::Bitmap:
CHECK(output_surface_->BindToClient(&output_surface_client_));
CHECK(child_output_surface_->BindToClient(&child_output_surface_client_));
- shared_bitmap_manager_.reset(new TestSharedBitmapManager());
+ shared_bitmap_manager_.reset(new TestSharedBitmapManager);
+ gpu_memory_buffer_manager_.reset(new TestGpuMemoryBufferManager);
resource_provider_ =
ResourceProvider::Create(output_surface_.get(),
shared_bitmap_manager_.get(),
+ gpu_memory_buffer_manager_.get(),
main_thread_task_runner_.get(),
0,
false,
- 1,
- false);
+ 1);
child_resource_provider_ =
ResourceProvider::Create(child_output_surface_.get(),
shared_bitmap_manager_.get(),
+ gpu_memory_buffer_manager_.get(),
main_thread_task_runner_.get(),
0,
false,
- 1,
- false);
+ 1);
}
static void CollectResources(ReturnedResourceArray* array,
scoped_ptr<ResourceProvider> resource_provider_;
scoped_ptr<ResourceProvider> child_resource_provider_;
scoped_ptr<TestSharedBitmapManager> shared_bitmap_manager_;
+ scoped_ptr<TestGpuMemoryBufferManager> gpu_memory_buffer_manager_;
};
void CheckCreateResource(ResourceProvider::ResourceType expected_default_type,
ResourceProvider::ResourceId id3 = child_resource_provider_->CreateResource(
size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
- child_resource_provider_->AcquireImage(id3);
- int stride;
- child_resource_provider_->MapImage(id3, &stride);
- child_resource_provider_->UnmapImage(id3);
+ {
+ ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock(
+ child_resource_provider_.get(), id3);
+ EXPECT_TRUE(!!lock.GetGpuMemoryBuffer());
+ }
GLuint external_texture_id = child_context_->createExternalTexture();
child_context_->bindTexture(GL_TEXTURE_EXTERNAL_OES, external_texture_id);
ResourceProviderContext::Create(shared_data_.get()));
FakeOutputSurfaceClient child_output_surface_client;
- scoped_ptr<OutputSurface> child_output_surface(FakeOutputSurface::Create3d(
- child_context_owned.PassAs<TestWebGraphicsContext3D>()));
+ scoped_ptr<OutputSurface> child_output_surface(
+ FakeOutputSurface::Create3d(child_context_owned.Pass()));
CHECK(child_output_surface->BindToClient(&child_output_surface_client));
scoped_ptr<ResourceProvider> child_resource_provider(
ResourceProvider::Create(child_output_surface.get(),
shared_bitmap_manager_.get(),
+ gpu_memory_buffer_manager_.get(),
NULL,
0,
false,
- 1,
- false));
+ 1));
gfx::Size size(1, 1);
ResourceFormat format = RGBA_8888;
// Destroy the parent resource provider. The resource that's left should be
// lost at this point, and returned.
- resource_provider_.reset();
+ resource_provider_ = nullptr;
ASSERT_EQ(1u, returned_to_child.size());
if (GetParam() == ResourceProvider::GLTexture) {
EXPECT_NE(0u, returned_to_child[0].sync_point);
TextureStateTrackingContext* child_context = child_context_owned.get();
FakeOutputSurfaceClient child_output_surface_client;
- scoped_ptr<OutputSurface> child_output_surface(FakeOutputSurface::Create3d(
- child_context_owned.PassAs<TestWebGraphicsContext3D>()));
+ scoped_ptr<OutputSurface> child_output_surface(
+ FakeOutputSurface::Create3d(child_context_owned.Pass()));
CHECK(child_output_surface->BindToClient(&child_output_surface_client));
scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
new TestSharedBitmapManager());
ResourceProvider::Create(child_output_surface.get(),
shared_bitmap_manager.get(),
NULL,
+ NULL,
0,
false,
- 1,
- false));
+ 1));
scoped_ptr<TextureStateTrackingContext> parent_context_owned(
new TextureStateTrackingContext);
TextureStateTrackingContext* parent_context = parent_context_owned.get();
FakeOutputSurfaceClient parent_output_surface_client;
- scoped_ptr<OutputSurface> parent_output_surface(FakeOutputSurface::Create3d(
- parent_context_owned.PassAs<TestWebGraphicsContext3D>()));
+ scoped_ptr<OutputSurface> parent_output_surface(
+ FakeOutputSurface::Create3d(parent_context_owned.Pass()));
CHECK(parent_output_surface->BindToClient(&parent_output_surface_client));
scoped_ptr<ResourceProvider> parent_resource_provider(
ResourceProvider::Create(parent_output_surface.get(),
shared_bitmap_manager.get(),
NULL,
+ NULL,
0,
false,
- 1,
- false));
+ 1));
gfx::Size size(1, 1);
ResourceFormat format = RGBA_8888;
EXPECT_EQ(0u, release_sync_point);
EXPECT_FALSE(lost_resource);
- child_resource_provider_.reset();
+ child_resource_provider_ = nullptr;
if (GetParam() == ResourceProvider::GLTexture) {
EXPECT_LE(sync_point, release_sync_point);
EXPECT_EQ(0u, release_sync_point);
EXPECT_FALSE(lost_resource);
- child_resource_provider_.reset();
+ child_resource_provider_ = nullptr;
// Since the resource is in the parent, the child considers it lost.
EXPECT_EQ(0u, release_sync_point);
EXPECT_EQ(NULL, main_thread_task_runner);
resource_provider_->DidLoseOutputSurface();
- resource_provider_.reset();
+ resource_provider_ = nullptr;
EXPECT_LE(sync_point, release_sync_point);
EXPECT_TRUE(lost_resource);
TextureStateTrackingContext* context = context_owned.get();
FakeOutputSurfaceClient output_surface_client;
- scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
- context_owned.PassAs<TestWebGraphicsContext3D>()));
+ scoped_ptr<OutputSurface> output_surface(
+ FakeOutputSurface::Create3d(context_owned.Pass()));
CHECK(output_surface->BindToClient(&output_surface_client));
scoped_ptr<ResourceProvider> resource_provider(
ResourceProvider::Create(output_surface.get(),
shared_bitmap_manager_.get(),
+ gpu_memory_buffer_manager_.get(),
NULL,
0,
false,
- 1,
- false));
+ 1));
gfx::Size size(1, 1);
ResourceFormat format = RGBA_8888;
TextureStateTrackingContext* context = context_owned.get();
FakeOutputSurfaceClient output_surface_client;
- scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
- context_owned.PassAs<TestWebGraphicsContext3D>()));
+ scoped_ptr<OutputSurface> output_surface(
+ FakeOutputSurface::Create3d(context_owned.Pass()));
CHECK(output_surface->BindToClient(&output_surface_client));
scoped_ptr<ResourceProvider> resource_provider(
ResourceProvider::Create(output_surface.get(),
shared_bitmap_manager_.get(),
+ gpu_memory_buffer_manager_.get(),
NULL,
0,
false,
- 1,
- false));
+ 1));
gfx::Size size(1, 1);
ResourceFormat format = RGBA_8888;
TextureStateTrackingContext* context = context_owned.get();
FakeOutputSurfaceClient output_surface_client;
- scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
- context_owned.PassAs<TestWebGraphicsContext3D>()));
+ scoped_ptr<OutputSurface> output_surface(
+ FakeOutputSurface::Create3d(context_owned.Pass()));
CHECK(output_surface->BindToClient(&output_surface_client));
scoped_ptr<ResourceProvider> resource_provider(
ResourceProvider::Create(output_surface.get(),
shared_bitmap_manager_.get(),
+ gpu_memory_buffer_manager_.get(),
NULL,
0,
false,
- 1,
- false));
+ 1));
gfx::Size size(1, 1);
ResourceFormat format = RGBA_8888;
context->set_support_texture_usage(true);
FakeOutputSurfaceClient output_surface_client;
- scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
- context_owned.PassAs<TestWebGraphicsContext3D>()));
+ scoped_ptr<OutputSurface> output_surface(
+ FakeOutputSurface::Create3d(context_owned.Pass()));
CHECK(output_surface->BindToClient(&output_surface_client));
scoped_ptr<ResourceProvider> resource_provider(
ResourceProvider::Create(output_surface.get(),
shared_bitmap_manager_.get(),
+ gpu_memory_buffer_manager_.get(),
NULL,
0,
false,
- 1,
- false));
+ 1));
gfx::Size size(1, 1);
ResourceFormat format = RGBA_8888;
scoped_ptr<ResourceProvider> resource_provider(
ResourceProvider::Create(output_surface.get(),
shared_bitmap_manager_.get(),
+ gpu_memory_buffer_manager_.get(),
main_thread_task_runner_.get(),
0,
false,
- 1,
- false));
+ 1));
uint32 release_sync_point = 0;
bool lost_resource = false;
TextureStateTrackingContext* context = context_owned.get();
FakeOutputSurfaceClient output_surface_client;
- scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
- context_owned.PassAs<TestWebGraphicsContext3D>()));
+ scoped_ptr<OutputSurface> output_surface(
+ FakeOutputSurface::Create3d(context_owned.Pass()));
CHECK(output_surface->BindToClient(&output_surface_client));
scoped_ptr<ResourceProvider> resource_provider(
ResourceProvider::Create(output_surface.get(),
shared_bitmap_manager_.get(),
+ gpu_memory_buffer_manager_.get(),
main_thread_task_runner_.get(),
0,
false,
- 1,
- false));
+ 1));
unsigned texture_id = 1;
uint32 sync_point = 30;
TextureStateTrackingContext* context = context_owned.get();
FakeOutputSurfaceClient output_surface_client;
- scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
- context_owned.PassAs<TestWebGraphicsContext3D>()));
+ scoped_ptr<OutputSurface> output_surface(
+ FakeOutputSurface::Create3d(context_owned.Pass()));
CHECK(output_surface->BindToClient(&output_surface_client));
scoped_ptr<ResourceProvider> resource_provider(
ResourceProvider::Create(output_surface.get(),
shared_bitmap_manager_.get(),
+ gpu_memory_buffer_manager_.get(),
NULL,
0,
false,
- 1,
- false));
+ 1));
unsigned texture_id = 1;
uint32 sync_point = 30;
TextureStateTrackingContext* context = context_owned.get();
FakeOutputSurfaceClient output_surface_client;
- scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
- context_owned.PassAs<TestWebGraphicsContext3D>()));
+ scoped_ptr<OutputSurface> output_surface(
+ FakeOutputSurface::Create3d(context_owned.Pass()));
CHECK(output_surface->BindToClient(&output_surface_client));
scoped_ptr<ResourceProvider> resource_provider(
ResourceProvider::Create(output_surface.get(),
shared_bitmap_manager_.get(),
+ gpu_memory_buffer_manager_.get(),
NULL,
0,
false,
- 1,
- false));
+ 1));
uint32 sync_point = 30;
unsigned target = GL_TEXTURE_2D;
TextureStateTrackingContext* context = context_owned.get();
FakeOutputSurfaceClient output_surface_client;
- scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
- context_owned.PassAs<TestWebGraphicsContext3D>()));
+ scoped_ptr<OutputSurface> output_surface(
+ FakeOutputSurface::Create3d(context_owned.Pass()));
CHECK(output_surface->BindToClient(&output_surface_client));
scoped_ptr<ResourceProvider> resource_provider(
ResourceProvider::Create(output_surface.get(),
shared_bitmap_manager_.get(),
+ gpu_memory_buffer_manager_.get(),
NULL,
0,
false,
- 1,
- false));
+ 1));
uint32 sync_point = 0;
unsigned target = GL_TEXTURE_2D;
GLsizei image_size,
const void* data));
MOCK_METHOD1(waitAsyncTexImage2DCHROMIUM, void(GLenum));
- MOCK_METHOD4(createImageCHROMIUM, GLuint(GLsizei, GLsizei, GLenum, GLenum));
+ MOCK_METHOD4(createImageCHROMIUM,
+ GLuint(ClientBuffer, GLsizei, GLsizei, GLenum));
MOCK_METHOD1(destroyImageCHROMIUM, void(GLuint));
- MOCK_METHOD1(mapImageCHROMIUM, void*(GLuint));
- MOCK_METHOD3(getImageParameterivCHROMIUM, void(GLuint, GLenum, GLint*));
- MOCK_METHOD1(unmapImageCHROMIUM, void(GLuint));
MOCK_METHOD2(bindTexImage2DCHROMIUM, void(GLenum, GLint));
MOCK_METHOD2(releaseTexImage2DCHROMIUM, void(GLenum, GLint));
AllocationTrackingContext3D* context = context_owned.get();
FakeOutputSurfaceClient output_surface_client;
- scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
- context_owned.PassAs<TestWebGraphicsContext3D>()));
+ scoped_ptr<OutputSurface> output_surface(
+ FakeOutputSurface::Create3d(context_owned.Pass()));
CHECK(output_surface->BindToClient(&output_surface_client));
scoped_ptr<ResourceProvider> resource_provider(
ResourceProvider::Create(output_surface.get(),
shared_bitmap_manager_.get(),
+ gpu_memory_buffer_manager_.get(),
NULL,
0,
false,
- 1,
- false));
+ 1));
gfx::Size size(2, 2);
gfx::Vector2d offset(0, 0);
context->set_support_texture_usage(true);
FakeOutputSurfaceClient output_surface_client;
- scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
- context_owned.PassAs<TestWebGraphicsContext3D>()));
+ scoped_ptr<OutputSurface> output_surface(
+ FakeOutputSurface::Create3d(context_owned.Pass()));
CHECK(output_surface->BindToClient(&output_surface_client));
scoped_ptr<ResourceProvider> resource_provider(
ResourceProvider::Create(output_surface.get(),
shared_bitmap_manager_.get(),
+ gpu_memory_buffer_manager_.get(),
NULL,
0,
false,
- 1,
- false));
+ 1));
gfx::Size size(2, 2);
context->set_support_texture_usage(true);
FakeOutputSurfaceClient output_surface_client;
- scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
- context_owned.PassAs<TestWebGraphicsContext3D>()));
+ scoped_ptr<OutputSurface> output_surface(
+ FakeOutputSurface::Create3d(context_owned.Pass()));
CHECK(output_surface->BindToClient(&output_surface_client));
scoped_ptr<ResourceProvider> resource_provider(
ResourceProvider::Create(output_surface.get(),
shared_bitmap_manager_.get(),
+ gpu_memory_buffer_manager_.get(),
NULL,
0,
false,
- 1,
- false));
+ 1));
gfx::Size size(2, 2);
const ResourceFormat formats[2] = {RGBA_8888, BGRA_8888};
AllocationTrackingContext3D* context = context_owned.get();
FakeOutputSurfaceClient output_surface_client;
- scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
- context_owned.PassAs<TestWebGraphicsContext3D>()));
+ scoped_ptr<OutputSurface> output_surface(
+ FakeOutputSurface::Create3d(context_owned.Pass()));
CHECK(output_surface->BindToClient(&output_surface_client));
gfx::Size size(2, 2);
scoped_ptr<ResourceProvider> resource_provider(
ResourceProvider::Create(output_surface.get(),
shared_bitmap_manager_.get(),
+ gpu_memory_buffer_manager_.get(),
NULL,
0,
false,
- 1,
- false));
+ 1));
id = resource_provider->CreateResource(
size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
AllocationTrackingContext3D* context = context_owned.get();
FakeOutputSurfaceClient output_surface_client;
- scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
- context_owned.PassAs<TestWebGraphicsContext3D>()));
+ scoped_ptr<OutputSurface> output_surface(
+ FakeOutputSurface::Create3d(context_owned.Pass()));
CHECK(output_surface->BindToClient(&output_surface_client));
gfx::Size size(2, 2);
scoped_ptr<ResourceProvider> resource_provider(
ResourceProvider::Create(output_surface.get(),
shared_bitmap_manager_.get(),
+ gpu_memory_buffer_manager_.get(),
NULL,
0,
false,
- 1,
- false));
+ 1));
id = resource_provider->CreateResource(
size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
AllocationTrackingContext3D* context = context_owned.get();
FakeOutputSurfaceClient output_surface_client;
- scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
- context_owned.PassAs<TestWebGraphicsContext3D>()));
+ scoped_ptr<OutputSurface> output_surface(
+ FakeOutputSurface::Create3d(context_owned.Pass()));
CHECK(output_surface->BindToClient(&output_surface_client));
gfx::Size size(2, 2);
scoped_ptr<ResourceProvider> resource_provider(
ResourceProvider::Create(output_surface.get(),
shared_bitmap_manager_.get(),
+ gpu_memory_buffer_manager_.get(),
NULL,
0,
false,
- 1,
- false));
+ 1));
EXPECT_CALL(*context, NextTextureId()).WillRepeatedly(Return(texture_id));
AllocationTrackingContext3D* context = context_owned.get();
FakeOutputSurfaceClient output_surface_client;
- scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
- context_owned.PassAs<TestWebGraphicsContext3D>()));
+ scoped_ptr<OutputSurface> output_surface(
+ FakeOutputSurface::Create3d(context_owned.Pass()));
CHECK(output_surface->BindToClient(&output_surface_client));
const int kWidth = 2;
scoped_ptr<ResourceProvider> resource_provider(
ResourceProvider::Create(output_surface.get(),
shared_bitmap_manager_.get(),
+ gpu_memory_buffer_manager_.get(),
NULL,
0,
false,
- 1,
- false));
+ 1));
id = resource_provider->CreateResource(
size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
- const int kStride = 4;
- void* dummy_mapped_buffer_address = NULL;
- EXPECT_CALL(
- *context,
- createImageCHROMIUM(kWidth, kHeight, GL_RGBA8_OES, GL_IMAGE_MAP_CHROMIUM))
+ EXPECT_CALL(*context, createImageCHROMIUM(_, kWidth, kHeight, GL_RGBA))
.WillOnce(Return(kImageId))
.RetiresOnSaturation();
- resource_provider->AcquireImage(id);
-
- EXPECT_CALL(*context, getImageParameterivCHROMIUM(kImageId,
- GL_IMAGE_ROWBYTES_CHROMIUM,
- _))
- .WillOnce(SetArgPointee<2>(kStride))
- .RetiresOnSaturation();
- EXPECT_CALL(*context, mapImageCHROMIUM(kImageId))
- .WillOnce(Return(dummy_mapped_buffer_address))
- .RetiresOnSaturation();
- int stride;
- resource_provider->MapImage(id, &stride);
-
- EXPECT_CALL(*context, unmapImageCHROMIUM(kImageId))
- .Times(1)
- .RetiresOnSaturation();
- resource_provider->UnmapImage(id);
+ {
+ ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock(
+ resource_provider.get(), id);
+ EXPECT_TRUE(!!lock.GetGpuMemoryBuffer());
+ }
EXPECT_CALL(*context, NextTextureId())
.WillOnce(Return(kTextureId))
EXPECT_EQ(kTextureId, lock_gl.texture_id());
}
- EXPECT_CALL(
- *context,
- getImageParameterivCHROMIUM(kImageId, GL_IMAGE_ROWBYTES_CHROMIUM, _))
- .WillOnce(SetArgPointee<2>(kStride))
- .RetiresOnSaturation();
- EXPECT_CALL(*context, mapImageCHROMIUM(kImageId))
- .WillOnce(Return(dummy_mapped_buffer_address))
- .RetiresOnSaturation();
- resource_provider->MapImage(id, &stride);
-
- EXPECT_CALL(*context, unmapImageCHROMIUM(kImageId))
- .Times(1)
- .RetiresOnSaturation();
- resource_provider->UnmapImage(id);
+ {
+ ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock(
+ resource_provider.get(), id);
+ EXPECT_TRUE(!!lock.GetGpuMemoryBuffer());
+ }
EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId)).Times(1)
.RetiresOnSaturation();
context_owned->set_support_sync_query(true);
FakeOutputSurfaceClient output_surface_client;
- scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
- context_owned.PassAs<TestWebGraphicsContext3D>()));
+ scoped_ptr<OutputSurface> output_surface(
+ FakeOutputSurface::Create3d(context_owned.Pass()));
ASSERT_TRUE(output_surface->BindToClient(&output_surface_client));
const int kWidth = 2;
scoped_ptr<ResourceProvider> resource_provider(
ResourceProvider::Create(output_surface.get(),
shared_bitmap_manager_.get(),
+ gpu_memory_buffer_manager_.get(),
NULL,
0,
false,
- 1,
- false));
+ 1));
source_id = resource_provider->CreateResource(
size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
- const int kStride = 4;
- void* dummy_mapped_buffer_address = NULL;
- EXPECT_CALL(
- *context,
- createImageCHROMIUM(kWidth, kHeight, GL_RGBA8_OES, GL_IMAGE_MAP_CHROMIUM))
+ EXPECT_CALL(*context, createImageCHROMIUM(_, kWidth, kHeight, GL_RGBA))
.WillOnce(Return(kImageId))
.RetiresOnSaturation();
- EXPECT_CALL(
- *context,
- getImageParameterivCHROMIUM(kImageId, GL_IMAGE_ROWBYTES_CHROMIUM, _))
- .WillOnce(SetArgPointee<2>(kStride))
- .RetiresOnSaturation();
- EXPECT_CALL(*context, mapImageCHROMIUM(kImageId))
- .WillOnce(Return(dummy_mapped_buffer_address))
- .RetiresOnSaturation();
- resource_provider->AcquireImage(source_id);
- int stride;
- resource_provider->MapImage(source_id, &stride);
- EXPECT_CALL(*context, unmapImageCHROMIUM(kImageId))
- .Times(1)
- .RetiresOnSaturation();
- resource_provider->UnmapImage(source_id);
+ {
+ ResourceProvider::ScopedWriteLockGpuMemoryBuffer lock(
+ resource_provider.get(), source_id);
+ EXPECT_TRUE(!!lock.GetGpuMemoryBuffer());
+ }
Mock::VerifyAndClearExpectations(context);
dest_id = resource_provider->CreateResource(
ResourceProviderContext* context = context_owned.get();
scoped_refptr<TestContextProvider> context_provider =
- TestContextProvider::Create(
- context_owned.PassAs<TestWebGraphicsContext3D>());
+ TestContextProvider::Create(context_owned.Pass());
output_surface->InitializeAndSetContext3d(context_provider);
resource_provider->InitializeGL();
ResourceProvider::Create(output_surface.get(),
shared_bitmap_manager.get(),
NULL,
+ NULL,
0,
false,
- 1,
- false));
+ 1));
CheckCreateResource(ResourceProvider::Bitmap, resource_provider.get(), NULL);
context_owned->set_support_compressed_texture_etc1(true);
FakeOutputSurfaceClient output_surface_client;
- scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
- context_owned.PassAs<TestWebGraphicsContext3D>()));
+ scoped_ptr<OutputSurface> output_surface(
+ FakeOutputSurface::Create3d(context_owned.Pass()));
CHECK(output_surface->BindToClient(&output_surface_client));
gfx::Size size(4, 4);
scoped_ptr<ResourceProvider> resource_provider(
ResourceProvider::Create(output_surface.get(),
shared_bitmap_manager_.get(),
+ gpu_memory_buffer_manager_.get(),
NULL,
0,
false,
- 1,
- false));
+ 1));
int texture_id = 123;
ResourceProvider::ResourceId id = resource_provider->CreateResource(
context_owned->set_support_compressed_texture_etc1(true);
FakeOutputSurfaceClient output_surface_client;
- scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
- context_owned.PassAs<TestWebGraphicsContext3D>()));
+ scoped_ptr<OutputSurface> output_surface(
+ FakeOutputSurface::Create3d(context_owned.Pass()));
CHECK(output_surface->BindToClient(&output_surface_client));
gfx::Size size(4, 4);
scoped_ptr<ResourceProvider> resource_provider(
ResourceProvider::Create(output_surface.get(),
shared_bitmap_manager_.get(),
+ gpu_memory_buffer_manager_.get(),
NULL,
0,
false,
- 1,
- false));
+ 1));
int texture_id = 123;
uint8_t pixels[8];
class TextureIdAllocationTrackingContext : public TestWebGraphicsContext3D {
public:
- virtual GLuint NextTextureId() OVERRIDE {
+ GLuint NextTextureId() override {
base::AutoLock lock(namespace_->lock);
return namespace_->next_texture_id++;
}
- virtual void RetireTextureId(GLuint) OVERRIDE {}
+ void RetireTextureId(GLuint) override {}
GLuint PeekTextureId() {
base::AutoLock lock(namespace_->lock);
return namespace_->next_texture_id;
TextureIdAllocationTrackingContext* context = context_owned.get();
FakeOutputSurfaceClient output_surface_client;
- scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
- context_owned.PassAs<TestWebGraphicsContext3D>()));
+ scoped_ptr<OutputSurface> output_surface(
+ FakeOutputSurface::Create3d(context_owned.Pass()));
CHECK(output_surface->BindToClient(&output_surface_client));
scoped_ptr<SharedBitmapManager> shared_bitmap_manager(
new TestSharedBitmapManager());
ResourceProvider::Create(output_surface.get(),
shared_bitmap_manager.get(),
NULL,
+ NULL,
0,
false,
- kTextureAllocationChunkSize,
- false));
+ kTextureAllocationChunkSize));
ResourceProvider::ResourceId id = resource_provider->CreateResource(
size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);
ResourceProvider::Create(output_surface.get(),
shared_bitmap_manager.get(),
NULL,
+ NULL,
0,
false,
- kTextureAllocationChunkSize,
- false));
+ kTextureAllocationChunkSize));
ResourceProvider::ResourceId id = resource_provider->CreateResource(
size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureHintImmutable, format);