Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(784)

Unified Diff: cc/resources/resource_provider_unittest.cc

Issue 27973002: cc: Adding ETC1 support to UIResourceBitmap and ResourceProvider (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments, added test, dcheck for compressed texture availability Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/resources/resource_provider_unittest.cc
diff --git a/cc/resources/resource_provider_unittest.cc b/cc/resources/resource_provider_unittest.cc
index 05a10a2352f25fa5db07674590092808ae5a86b8..a21bfd2bcd1dfbe62a86fa8fb7bbcfc2f2c9aa18 100644
--- a/cc/resources/resource_provider_unittest.cc
+++ b/cc/resources/resource_provider_unittest.cc
@@ -14,6 +14,7 @@
#include "cc/debug/test_texture.h"
#include "cc/debug/test_web_graphics_context_3d.h"
#include "cc/output/output_surface.h"
+#include "cc/resources/resource.h"
kaanb 2013/10/23 20:30:09 do you need this include? Please remove it if IWYU
kaanb 2013/10/23 20:30:09 Please remove this include if IWYU presubmit check
powei 2013/10/23 22:20:07 Done.
#include "cc/resources/returned_resource.h"
#include "cc/resources/single_release_callback.h"
#include "cc/test/fake_output_surface.h"
@@ -2124,6 +2125,25 @@ class AllocationTrackingContext3D : public TestWebGraphicsContext3D {
WGC3Denum format,
WGC3Denum type,
const void* pixels));
+ MOCK_METHOD8(compressedTexImage2D,
+ void(WGC3Denum target,
+ WGC3Dint level,
+ WGC3Denum internalformat,
+ WGC3Dsizei width,
+ WGC3Dsizei height,
+ WGC3Dint border,
+ WGC3Dsizei imageSize,
kaanb 2013/10/23 20:30:09 nit: s/imageSize/image_size/ also fix the other mo
powei 2013/10/23 22:20:07 Done.
+ const void* data));
+ MOCK_METHOD9(compressedTexSubImage2D,
+ void(WGC3Denum target,
+ WGC3Dint level,
+ WGC3Dint xoffset,
+ WGC3Dint yoffset,
+ WGC3Dsizei width,
+ WGC3Dsizei height,
+ WGC3Denum format,
+ WGC3Dsizei imageSize,
+ const void* data));
MOCK_METHOD1(waitAsyncTexImage2DCHROMIUM, void(WGC3Denum));
MOCK_METHOD3(createImageCHROMIUM, WGC3Duint(WGC3Dsizei, WGC3Dsizei,
WGC3Denum));
@@ -2548,6 +2568,61 @@ TEST(ResourceProviderTest, BasicInitializeGLSoftware) {
output_surface.get());
}
+TEST_P(ResourceProviderTest, CompressedTextureETC1) {
+ if (GetParam() != ResourceProvider::GLTexture)
+ return;
+
+ scoped_ptr<AllocationTrackingContext3D> context_owned(
+ new AllocationTrackingContext3D);
+ AllocationTrackingContext3D* context = context_owned.get();
+ context_owned->set_support_compressed_texture_etc1(true);
+
+ FakeOutputSurfaceClient output_surface_client;
+ scoped_ptr<OutputSurface> output_surface(FakeOutputSurface::Create3d(
+ context_owned.PassAs<TestWebGraphicsContext3D>()));
+ CHECK(output_surface->BindToClient(&output_surface_client));
+
+ gfx::Size size(4, 4);
+ ResourceFormat format = ETC1;
kaanb 2013/10/23 20:30:09 consider hardcoding ETC1 while calling ResourcePro
powei 2013/10/23 22:20:07 Done.
+ ResourceProvider::ResourceId id = 0;
+
+ scoped_ptr<ResourceProvider> resource_provider(
+ ResourceProvider::Create(output_surface.get(), 0, false));
+ int texture_id = 123;
+
+ id = resource_provider->CreateResource(
kaanb 2013/10/23 20:30:09 you can define id here
powei 2013/10/23 22:20:07 Done.
+ size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format);
+ EXPECT_NE(0u, id);
+ EXPECT_CALL(*context, createTexture()).WillOnce(Return(texture_id));
+ EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(2);
+ EXPECT_CALL(*context, compressedTexImage2D(_, _, _, _, _, _, _, _)).Times(1);
+ resource_provider->AllocateForTesting(id);
+
+ EXPECT_CALL(*context, deleteTexture(texture_id)).Times(1);
+ resource_provider->DeleteResource(id);
+ Mock::VerifyAndClearExpectations(context);
+
+ uint8_t pixels[8];
+
+ id = resource_provider->CreateResource(
kaanb 2013/10/23 20:30:09 consider moving this part into its own test case
powei 2013/10/23 22:20:07 Done.
+ size, GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, format);
+ EXPECT_NE(0u, id);
+ EXPECT_CALL(*context, createTexture()).WillOnce(Return(texture_id));
+ EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, texture_id)).Times(3);
+ EXPECT_CALL(*context,
+ compressedTexImage2D(
+ _, 0, _, size.width(), size.height(), _, _, _)).Times(1);
+ EXPECT_CALL(*context,
+ compressedTexSubImage2D(
+ _, 0, 0, 0, size.width(), size.height(), _, 8, _)).Times(1);
+ resource_provider->SetPixels(
+ id, pixels, gfx::Rect(size), gfx::Rect(size), gfx::Vector2d(0, 0));
+
+ EXPECT_CALL(*context, deleteTexture(texture_id)).Times(1);
+ resource_provider->DeleteResource(id);
+ Mock::VerifyAndClearExpectations(context);
+}
+
INSTANTIATE_TEST_CASE_P(
ResourceProviderTests,
ResourceProviderTest,

Powered by Google App Engine
This is Rietveld 408576698