Remove TextureCache and TextureUploader. These classes are now defunct and have no remaining clients. BUG= Review URL: https://codereview.chromium.org/1533753002 .
diff --git a/mojo/BUILD.gn b/mojo/BUILD.gn index 261fc8d..5302355 100644 --- a/mojo/BUILD.gn +++ b/mojo/BUILD.gn
@@ -66,7 +66,6 @@ "//mojo/edk:tests", "//mojo/file_utils:file_utils_apptests", "//mojo/gles2:mgl_unittests", - "//mojo/gpu:apptests", "//mojo/public/cpp/bindings/tests:versioning_apptests", "//mojo/services/files/c:apptests", "//mojo/services/files/cpp:files_impl_apptests",
diff --git a/mojo/gpu/BUILD.gn b/mojo/gpu/BUILD.gn index 27d2723..e0b3447 100644 --- a/mojo/gpu/BUILD.gn +++ b/mojo/gpu/BUILD.gn
@@ -16,10 +16,6 @@ "mojo_context_support.h", "mojo_gles2_impl_autogen.cc", "mojo_gles2_impl_autogen.h", - "texture_cache.cc", - "texture_cache.h", - "texture_uploader.cc", - "texture_uploader.h", ] public_deps = [ @@ -42,30 +38,5 @@ "//mojo/services/geometry/cpp", "//mojo/services/geometry/interfaces", "//mojo/services/gpu/interfaces", - "//mojo/services/surfaces/cpp", - "//mojo/services/surfaces/interfaces", - "//mojo/services/surfaces/interfaces:surface_id", - ] -} - -mojo_native_application("apptests") { - output_name = "texture_apptests" - - testonly = true - - sources = [ - "texture_cache_unittest.cc", - "texture_uploader_unittest.cc", - ] - - deps = [ - ":gpu", - "//base", - "//mojo/application", - "//mojo/application:test_support", - "//mojo/public/cpp/bindings:callback", - "//mojo/services/geometry/interfaces", - "//mojo/services/surfaces/interfaces:surface_id", - "//testing/gtest", ] }
diff --git a/mojo/gpu/texture_cache.cc b/mojo/gpu/texture_cache.cc deleted file mode 100644 index a76fedb..0000000 --- a/mojo/gpu/texture_cache.cc +++ /dev/null
@@ -1,104 +0,0 @@ -// Copyright 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef GL_GLEXT_PROTOTYPES -#define GL_GLEXT_PROTOTYPES -#endif -#include <GLES2/gl2extmojo.h> - -#include "mojo/gpu/gl_context.h" -#include "mojo/gpu/gl_texture.h" -#include "mojo/gpu/texture_cache.h" -#include "mojo/services/geometry/interfaces/geometry.mojom.h" - -namespace mojo { - -TextureCache::TextureInfo::TextureInfo() : texture_(), resource_id_(0u) {} -TextureCache::TextureInfo::TextureInfo(scoped_ptr<mojo::GLTexture> texture, - uint32_t resource_id) - : texture_(texture.Pass()), resource_id_(resource_id) {} -TextureCache::TextureInfo::~TextureInfo() {} - -TextureCache::TextureCache(base::WeakPtr<mojo::GLContext> gl_context, - mojo::ResourceReturnerPtr* out_resource_returner) - : gl_context_(gl_context), returner_binding_(this), next_resource_id_(0u) { - if (out_resource_returner) { - returner_binding_.Bind(GetProxy(out_resource_returner)); - } -} - -TextureCache::~TextureCache() {} - -scoped_ptr<TextureCache::TextureInfo> TextureCache::GetTexture( - const mojo::Size& requested_size) { - // Sift through our available textures to find one the correct size. If one - // exists use it. As we find textures of the wrong size, clean them up. - while (!available_textures_.empty()) { - // Get the next available texture's resource id. - uint32_t available_resource_id = available_textures_.front(); - available_textures_.pop_front(); - - // Get the texture information from the texture map. - auto texture_iterator = - resource_to_texture_map_.find(available_resource_id); - mojo::Size texture_size = texture_iterator->second->size(); - scoped_ptr<TextureInfo> texture_info(new TextureInfo( - texture_iterator->second.Pass(), texture_iterator->first)); - resource_to_texture_map_.erase(texture_iterator); - - // Get the sync point from the sync point map. - auto sync_point_iterator = - resource_to_sync_point_map_.find(available_resource_id); - int sync_point = sync_point_iterator->second; - resource_to_sync_point_map_.erase(sync_point_iterator); - - // If the texture is the right size, use it. - if (texture_size.width == requested_size.width && - texture_size.height == requested_size.height) { - gl_context_->MakeCurrent(); - glWaitSyncPointCHROMIUM(sync_point); - return texture_info; - } - } - - // If our context is invalid return an empty scoped ptr. - if (!gl_context_) { - return scoped_ptr<TextureInfo>(); - } - - // We couldn't find an existing texture to reuse, create a new one! - scoped_ptr<mojo::GLTexture> new_texture( - new mojo::GLTexture(gl_context_, requested_size)); - next_resource_id_++; - scoped_ptr<TextureInfo> texture_info( - new TextureInfo(new_texture.Pass(), next_resource_id_)); - return texture_info; -} - -void TextureCache::NotifyPendingResourceReturn( - uint32_t resource_id, - scoped_ptr<mojo::GLTexture> texture) { - resource_to_texture_map_[resource_id] = texture.Pass(); -} - -// mojo::ResourceReturner -void TextureCache::ReturnResources( - mojo::Array<mojo::ReturnedResourcePtr> resources) { - if (!gl_context_) { - return; - } - gl_context_->MakeCurrent(); - for (size_t i = 0u; i < resources.size(); ++i) { - mojo::ReturnedResourcePtr resource = resources[i].Pass(); - DCHECK_EQ(1, resource->count); - auto it = resource_to_texture_map_.find(resource->id); - // Ignore the returned resource if we haven't been notified of its pending - // return. - if (it != resource_to_texture_map_.end()) { - available_textures_.push_back(resource->id); - resource_to_sync_point_map_[resource->id] = resource->sync_point; - } - } -} -} // namespace mojo
diff --git a/mojo/gpu/texture_cache.h b/mojo/gpu/texture_cache.h deleted file mode 100644 index 347d7c5..0000000 --- a/mojo/gpu/texture_cache.h +++ /dev/null
@@ -1,81 +0,0 @@ -// Copyright 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef MOJO_GPU_TEXTURE_CACHE_H_ -#define MOJO_GPU_TEXTURE_CACHE_H_ - -#include <GLES2/gl2.h> - -#include <deque> -#include <map> - -#include "base/macros.h" -#include "base/memory/scoped_ptr.h" -#include "base/memory/weak_ptr.h" -#include "mojo/public/cpp/bindings/binding.h" -#include "mojo/services/surfaces/interfaces/surfaces.mojom.h" - -namespace mojo { - -class GLContext; -class GLTexture; -class Size; - -// Represents a cache of textures which can be drawn to and submitted to a -// surface. -// Each |texture| in the cache has an associated |resource_id| which must be -// used when the texture is submitted to a surface via a -// TransferableResourcePtr. This class must also be hooked up to the surface as -// a ResourceReturner such that the resources are properly marked as available -// to be used again. -class TextureCache : public mojo::ResourceReturner { - public: - class TextureInfo { - public: - TextureInfo(); - TextureInfo(scoped_ptr<mojo::GLTexture> texture, uint32_t resource_id); - ~TextureInfo(); - scoped_ptr<mojo::GLTexture> TakeTexture() { return texture_.Pass(); } - uint32_t resource_id() { return resource_id_; } - - private: - scoped_ptr<mojo::GLTexture> texture_; - uint32_t resource_id_; - - DISALLOW_COPY_AND_ASSIGN(TextureInfo); - }; - - // Returns the ResourceReturner to be given to the surface the textures will - // be uploaded to via |out_resource_returner|. - TextureCache(base::WeakPtr<mojo::GLContext> gl_context, - mojo::ResourceReturnerPtr* out_resource_returner); - ~TextureCache() override; - - // Returns a texture for the given size. If no texture is available the - // scoped_ptr will be empty. - scoped_ptr<TextureInfo> GetTexture(const mojo::Size& requested_size); - - // Notifies the TextureCache to expect the given resource to be returned - // shortly. - void NotifyPendingResourceReturn(uint32_t resource_id, - scoped_ptr<mojo::GLTexture> texture); - - private: - // mojo::ResourceReturner - void ReturnResources( - mojo::Array<mojo::ReturnedResourcePtr> resources) override; - - base::WeakPtr<mojo::GLContext> gl_context_; - mojo::Binding<mojo::ResourceReturner> returner_binding_; - std::deque<uint32_t> available_textures_; - std::map<uint32_t, scoped_ptr<mojo::GLTexture>> resource_to_texture_map_; - std::map<uint32_t, GLuint> resource_to_sync_point_map_; - uint32_t next_resource_id_; - - DISALLOW_COPY_AND_ASSIGN(TextureCache); -}; - -} // namespace mojo - -#endif // MOJO_GPU_TEXTURE_CACHE_H_
diff --git a/mojo/gpu/texture_cache_unittest.cc b/mojo/gpu/texture_cache_unittest.cc deleted file mode 100644 index 1be7415..0000000 --- a/mojo/gpu/texture_cache_unittest.cc +++ /dev/null
@@ -1,208 +0,0 @@ -// Copyright 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "mojo/gpu/texture_cache.h" - -#include "base/bind.h" -#include "base/message_loop/message_loop.h" -#include "mojo/gpu/gl_context.h" -#include "mojo/gpu/gl_texture.h" -#include "mojo/public/cpp/application/application_impl.h" -#include "mojo/public/cpp/application/application_test_base.h" -#include "mojo/services/geometry/interfaces/geometry.mojom.h" -#include "mojo/services/surfaces/interfaces/surface_id.mojom.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace { - -static const base::TimeDelta kDefaultMessageDelay = - base::TimeDelta::FromMilliseconds(20); - -class TextureCacheTest : public mojo::test::ApplicationTestBase { - public: - TextureCacheTest() : weak_factory_(this) {} - ~TextureCacheTest() override {} - - void SetUp() override { - mojo::test::ApplicationTestBase::SetUp(); - gl_context_ = mojo::GLContext::Create(application_impl()->shell()); - quit_message_loop_callback_ = base::Bind( - &TextureCacheTest::QuitMessageLoopCallback, weak_factory_.GetWeakPtr()); - } - - void QuitMessageLoopCallback() { base::MessageLoop::current()->Quit(); } - - void KickMessageLoop() { - base::MessageLoop::current()->PostDelayedTask( - FROM_HERE, quit_message_loop_callback_, kDefaultMessageDelay); - base::MessageLoop::current()->Run(); - } - - protected: - base::WeakPtr<mojo::GLContext> gl_context_; - base::Closure quit_message_loop_callback_; - base::WeakPtrFactory<TextureCacheTest> weak_factory_; - - private: - DISALLOW_COPY_AND_ASSIGN(TextureCacheTest); -}; - -TEST_F(TextureCacheTest, GetTextureOnce) { - mojo::TextureCache texture_cache(gl_context_, nullptr); - mojo::Size size; - size.width = 100; - size.height = 100; - scoped_ptr<mojo::TextureCache::TextureInfo> texture_info( - texture_cache.GetTexture(size).Pass()); - EXPECT_NE(texture_info->TakeTexture().get(), nullptr); -} - -TEST_F(TextureCacheTest, GetTextureTwice) { - mojo::TextureCache texture_cache(gl_context_, nullptr); - mojo::Size size; - size.width = 100; - size.height = 100; - scoped_ptr<mojo::TextureCache::TextureInfo> texture_info_1( - texture_cache.GetTexture(size).Pass()); - scoped_ptr<mojo::GLTexture> texture_1(texture_info_1->TakeTexture().Pass()); - scoped_ptr<mojo::TextureCache::TextureInfo> texture_info_2( - texture_cache.GetTexture(size).Pass()); - scoped_ptr<mojo::GLTexture> texture_2(texture_info_2->TakeTexture().Pass()); - - EXPECT_NE(texture_1.get(), nullptr); - EXPECT_NE(texture_2.get(), nullptr); - EXPECT_NE(texture_1.get(), texture_2.get()); - EXPECT_NE(texture_info_1->resource_id(), texture_info_2->resource_id()); -} - -TEST_F(TextureCacheTest, GetTextureAfterReturnSameSize) { - mojo::ResourceReturnerPtr resource_returner; - mojo::TextureCache texture_cache(gl_context_, &resource_returner); - mojo::Size size; - size.width = 100; - size.height = 100; - - // get a texture - scoped_ptr<mojo::TextureCache::TextureInfo> texture_info_1( - texture_cache.GetTexture(size).Pass()); - scoped_ptr<mojo::GLTexture> texture(texture_info_1->TakeTexture().Pass()); - mojo::GLTexture* texture_ptr = texture.get(); - EXPECT_NE(texture_ptr, nullptr); - - mojo::Array<mojo::ReturnedResourcePtr> resources; - mojo::ReturnedResourcePtr returnedResource = mojo::ReturnedResource::New(); - returnedResource->id = texture_info_1->resource_id(); - returnedResource->sync_point = 0u; - returnedResource->count = 1u; - returnedResource->lost = false; - resources.push_back(returnedResource.Pass()); - - // return the texture via resource id - texture_cache.NotifyPendingResourceReturn(texture_info_1->resource_id(), - texture.Pass()); - resource_returner->ReturnResources(resources.Pass()); - - KickMessageLoop(); - - // get a texture of the same size - it should be the same one as before - scoped_ptr<mojo::TextureCache::TextureInfo> texture_info_2( - texture_cache.GetTexture(size).Pass()); - scoped_ptr<mojo::GLTexture> texture_2(texture_info_2->TakeTexture().Pass()); - - EXPECT_NE(texture_2.get(), nullptr); - EXPECT_EQ(size.width, texture_2->size().width); - EXPECT_EQ(size.height, texture_2->size().height); - EXPECT_EQ(texture_info_1->resource_id(), texture_info_2->resource_id()); -} - -TEST_F(TextureCacheTest, GetTextureAfterReturnDifferentSize) { - mojo::ResourceReturnerPtr resource_returner; - mojo::TextureCache texture_cache(gl_context_, &resource_returner); - mojo::Size size; - size.width = 100; - size.height = 100; - - // get a texture - scoped_ptr<mojo::TextureCache::TextureInfo> texture_info_1( - texture_cache.GetTexture(size).Pass()); - scoped_ptr<mojo::GLTexture> texture(texture_info_1->TakeTexture().Pass()); - mojo::GLTexture* texture_ptr = texture.get(); - EXPECT_NE(texture_ptr, nullptr); - - mojo::Array<mojo::ReturnedResourcePtr> resources; - mojo::ReturnedResourcePtr returnedResource = mojo::ReturnedResource::New(); - returnedResource->id = texture_info_1->resource_id(); - returnedResource->sync_point = 0u; - returnedResource->count = 1u; - returnedResource->lost = false; - resources.push_back(returnedResource.Pass()); - - // return the texture via resource id - texture_cache.NotifyPendingResourceReturn(texture_info_1->resource_id(), - texture.Pass()); - resource_returner->ReturnResources(resources.Pass()); - - KickMessageLoop(); - - mojo::Size different_size; - different_size.width = size.width - 1; - different_size.height = size.height - 1; - - // get a texture of the different size - it should not be the same one as - // before - scoped_ptr<mojo::TextureCache::TextureInfo> texture_info_2( - texture_cache.GetTexture(different_size).Pass()); - scoped_ptr<mojo::GLTexture> texture_2(texture_info_2->TakeTexture().Pass()); - - EXPECT_NE(texture_2.get(), nullptr); - EXPECT_NE(size.width, texture_2->size().width); - EXPECT_NE(size.height, texture_2->size().height); - EXPECT_EQ(different_size.width, texture_2->size().width); - EXPECT_EQ(different_size.height, texture_2->size().height); - EXPECT_NE(texture_info_1->resource_id(), texture_info_2->resource_id()); -} - -TEST_F(TextureCacheTest, GetTextureReleasedGlContext) { - gl_context_.reset(); - mojo::TextureCache texture_cache(gl_context_, nullptr); - mojo::Size size; - size.width = 100; - size.height = 100; - - EXPECT_EQ(texture_cache.GetTexture(size).get(), nullptr); -} - -TEST_F(TextureCacheTest, ReturnResourcesReleasedGlContext) { - mojo::ResourceReturnerPtr resource_returner; - mojo::TextureCache texture_cache(gl_context_, &resource_returner); - mojo::Size size; - size.width = 100; - size.height = 100; - - // get a texture - scoped_ptr<mojo::TextureCache::TextureInfo> texture_info( - texture_cache.GetTexture(size).Pass()); - scoped_ptr<mojo::GLTexture> texture(texture_info->TakeTexture().Pass()); - mojo::GLTexture* texture_ptr = texture.get(); - EXPECT_NE(texture_ptr, nullptr); - - gl_context_.reset(); - - mojo::Array<mojo::ReturnedResourcePtr> resources; - mojo::ReturnedResourcePtr returnedResource = mojo::ReturnedResource::New(); - returnedResource->id = texture_info->resource_id(); - returnedResource->sync_point = 0u; - returnedResource->count = 1u; - returnedResource->lost = false; - resources.push_back(returnedResource.Pass()); - - // return the texture via resource id - texture_cache.NotifyPendingResourceReturn(texture_info->resource_id(), - texture.Pass()); - resource_returner->ReturnResources(resources.Pass()); - - KickMessageLoop(); -} - -} // namespace
diff --git a/mojo/gpu/texture_uploader.cc b/mojo/gpu/texture_uploader.cc deleted file mode 100644 index 5424f25..0000000 --- a/mojo/gpu/texture_uploader.cc +++ /dev/null
@@ -1,94 +0,0 @@ -// Copyright 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "mojo/gpu/texture_uploader.h" - -#ifndef GL_GLEXT_PROTOTYPES -#define GL_GLEXT_PROTOTYPES -#endif - -#include <GLES2/gl2.h> -#include <GLES2/gl2extmojo.h> - -#include "mojo/services/geometry/cpp/geometry_util.h" -#include "mojo/services/surfaces/cpp/surfaces_utils.h" - -namespace mojo { - -mojo::FramePtr TextureUploader::GetUploadFrame( - base::WeakPtr<mojo::GLContext> context, - uint32_t resource_id, - const scoped_ptr<mojo::GLTexture>& texture) { - if (!context) { - return mojo::FramePtr(); - } - - mojo::Size size = texture->size(); - - mojo::FramePtr frame = mojo::Frame::New(); - frame->resources.resize(0u); - - mojo::Rect bounds; - bounds.width = size.width; - bounds.height = size.height; - mojo::PassPtr pass = mojo::CreateDefaultPass(1, bounds); - pass->quads.resize(0u); - pass->shared_quad_states.push_back(mojo::CreateDefaultSQS(size)); - - context->MakeCurrent(); - glBindTexture(GL_TEXTURE_2D, texture->texture_id()); - GLbyte mailbox[GL_MAILBOX_SIZE_CHROMIUM]; - glGenMailboxCHROMIUM(mailbox); - glProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox); - GLuint sync_point = glInsertSyncPointCHROMIUM(); - - mojo::TransferableResourcePtr resource = mojo::TransferableResource::New(); - resource->id = resource_id; - resource->format = mojo::ResourceFormat::RGBA_8888; - resource->filter = GL_LINEAR; - resource->size = size.Clone(); - mojo::MailboxHolderPtr mailbox_holder = mojo::MailboxHolder::New(); - mailbox_holder->mailbox = mojo::Mailbox::New(); - for (int i = 0; i < GL_MAILBOX_SIZE_CHROMIUM; ++i) - mailbox_holder->mailbox->name.push_back(mailbox[i]); - mailbox_holder->texture_target = GL_TEXTURE_2D; - mailbox_holder->sync_point = sync_point; - resource->mailbox_holder = mailbox_holder.Pass(); - resource->is_repeated = false; - resource->is_software = false; - - mojo::QuadPtr quad = mojo::Quad::New(); - quad->material = mojo::Material::TEXTURE_CONTENT; - - mojo::RectPtr rect = mojo::Rect::New(); - rect->width = size.width; - rect->height = size.height; - quad->rect = rect.Clone(); - quad->opaque_rect = rect.Clone(); - quad->visible_rect = rect.Clone(); - quad->needs_blending = true; - quad->shared_quad_state_index = 0u; - - mojo::TextureQuadStatePtr texture_state = mojo::TextureQuadState::New(); - texture_state->resource_id = resource->id; - texture_state->premultiplied_alpha = true; - texture_state->uv_top_left = mojo::PointF::New(); - texture_state->uv_bottom_right = mojo::PointF::New(); - texture_state->uv_bottom_right->x = 1.f; - texture_state->uv_bottom_right->y = 1.f; - texture_state->background_color = mojo::Color::New(); - texture_state->background_color->rgba = 0; - for (int i = 0; i < 4; ++i) - texture_state->vertex_opacity.push_back(1.f); - texture_state->flipped = false; - - frame->resources.push_back(resource.Pass()); - quad->texture_quad_state = texture_state.Pass(); - pass->quads.push_back(quad.Pass()); - - frame->passes.push_back(pass.Pass()); - return frame; -} - -} // namespace mojo
diff --git a/mojo/gpu/texture_uploader.h b/mojo/gpu/texture_uploader.h deleted file mode 100644 index 29ab680..0000000 --- a/mojo/gpu/texture_uploader.h +++ /dev/null
@@ -1,34 +0,0 @@ -// Copyright 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef MOJO_GPU_TEXTURE_UPLOADER_H_ -#define MOJO_GPU_TEXTURE_UPLOADER_H_ - -#include "base/memory/scoped_ptr.h" -#include "base/memory/weak_ptr.h" -#include "mojo/gpu/gl_context.h" -#include "mojo/gpu/gl_texture.h" -#include "mojo/services/surfaces/interfaces/surfaces.mojom.h" - -namespace mojo { - -// Utility class for uploading textures to a surface. -class TextureUploader { - public: - // Gets a FramePtr for uploading to a to a SurfacePtr using |texture| as a - // transferable resource with id |resource_id|. - static mojo::FramePtr GetUploadFrame( - base::WeakPtr<mojo::GLContext> context, - uint32_t resource_id, - const scoped_ptr<mojo::GLTexture>& texture); - - private: - TextureUploader(); - ~TextureUploader(); - DISALLOW_COPY_AND_ASSIGN(TextureUploader); -}; - -} // namespace mojo - -#endif // MOJO_GPU_TEXTURE_UPLOADER_H_
diff --git a/mojo/gpu/texture_uploader_unittest.cc b/mojo/gpu/texture_uploader_unittest.cc deleted file mode 100644 index b8c553e..0000000 --- a/mojo/gpu/texture_uploader_unittest.cc +++ /dev/null
@@ -1,60 +0,0 @@ -// Copyright 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "mojo/gpu/texture_uploader.h" - -#include "base/bind.h" -#include "base/message_loop/message_loop.h" -#include "mojo/gpu/texture_cache.h" -#include "mojo/public/cpp/application/application_impl.h" -#include "mojo/public/cpp/application/application_test_base.h" -#include "mojo/public/cpp/application/connect.h" -#include "mojo/services/surfaces/interfaces/surface_id.mojom.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace { - -class TextureUploaderTest : public mojo::test::ApplicationTestBase { - public: - TextureUploaderTest() : surface_id_(1u), weak_factory_(this) {} - ~TextureUploaderTest() override {} - - void SetUp() override { - mojo::test::ApplicationTestBase::SetUp(); - - mojo::ServiceProviderPtr surfaces_service_provider; - application_impl()->shell()->ConnectToApplication( - "mojo:surfaces_service", mojo::GetProxy(&surfaces_service_provider), - nullptr); - mojo::ConnectToService(surfaces_service_provider.get(), &surface_); - gl_context_ = mojo::GLContext::Create(application_impl()->shell()); - surface_->CreateSurface(surface_id_); - texture_cache_.reset(new mojo::TextureCache(gl_context_, nullptr)); - } - - void OnFrameCompleteExit() { base::MessageLoop::current()->Quit(); } - - protected: - uint32_t surface_id_; - base::WeakPtr<mojo::GLContext> gl_context_; - scoped_ptr<mojo::TextureCache> texture_cache_; - mojo::SurfacePtr surface_; - base::WeakPtrFactory<TextureUploaderTest> weak_factory_; - - private: - DISALLOW_COPY_AND_ASSIGN(TextureUploaderTest); -}; - -TEST_F(TextureUploaderTest, Base) { - mojo::Size size; - size.width = 100; - size.height = 100; - scoped_ptr<mojo::TextureCache::TextureInfo> texture_info( - texture_cache_->GetTexture(size).Pass()); - mojo::FramePtr frame = mojo::TextureUploader::GetUploadFrame( - gl_context_, texture_info->resource_id(), texture_info->TakeTexture()); - EXPECT_FALSE(frame.is_null()); -} - -} // namespace