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

Unified Diff: gpu/command_buffer/common/gles2_cmd_utils_unittest.cc

Issue 7046057: Fix LUMANINCE_ALPHA issue (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 6 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
« no previous file with comments | « gpu/command_buffer/common/gles2_cmd_utils.cc ('k') | gpu/gpu.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/common/gles2_cmd_utils_unittest.cc
===================================================================
--- gpu/command_buffer/common/gles2_cmd_utils_unittest.cc (revision 0)
+++ gpu/command_buffer/common/gles2_cmd_utils_unittest.cc (revision 0)
@@ -0,0 +1,98 @@
+// Copyright (c) 2011 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 "gpu/command_buffer/common/gles2_cmd_utils.h"
+
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+#include <GLES2/gles2_command_buffer.h>
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace gpu {
+namespace gles2 {
+
+class GLES2UtilTest : public testing:: Test {
+ public:
+ GLES2UtilTest()
+ : util_(0) {
+ }
+
+ protected:
+ GLES2Util util_;
+};
+
+TEST_F(GLES2UtilTest, ComputeImageDataSizeFormats) {
+ const int kWidth = 16;
+ const int kHeight = 12;
+ uint32 size;
+ EXPECT_TRUE(GLES2Util::ComputeImageDataSize(
+ kWidth, kHeight, GL_RGB, GL_UNSIGNED_BYTE, 1, &size));
+ EXPECT_EQ(kWidth * kHeight * 3, size);
+ EXPECT_TRUE(GLES2Util::ComputeImageDataSize(
+ kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, 1, &size));
+ EXPECT_EQ(kWidth * kHeight * 4, size);
+ EXPECT_TRUE(GLES2Util::ComputeImageDataSize(
+ kWidth, kHeight, GL_LUMINANCE, GL_UNSIGNED_BYTE, 1, &size));
+ EXPECT_EQ(kWidth * kHeight * 1, size);
+ EXPECT_TRUE(GLES2Util::ComputeImageDataSize(
+ kWidth, kHeight, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, 1, &size));
+ EXPECT_EQ(kWidth * kHeight * 2, size);
+ EXPECT_TRUE(GLES2Util::ComputeImageDataSize(
+ kWidth, kHeight, GL_BGRA_EXT, GL_UNSIGNED_BYTE, 1, &size));
+ EXPECT_EQ(kWidth * kHeight * 4, size);
+ EXPECT_TRUE(GLES2Util::ComputeImageDataSize(
+ kWidth, kHeight, GL_ALPHA, GL_UNSIGNED_BYTE, 1, &size));
+ EXPECT_EQ(kWidth * kHeight * 1, size);
+ EXPECT_TRUE(GLES2Util::ComputeImageDataSize(
+ kWidth, kHeight, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, 1, &size));
+ EXPECT_EQ(kWidth * kHeight * 2, size);
+ EXPECT_TRUE(GLES2Util::ComputeImageDataSize(
+ kWidth, kHeight, GL_DEPTH_STENCIL_OES, GL_UNSIGNED_INT_24_8_OES, 1,
+ &size));
+ EXPECT_EQ(kWidth * kHeight * 4, size);
+}
+
+TEST_F(GLES2UtilTest, ComputeImageDataSizeTypes) {
+ const int kWidth = 16;
+ const int kHeight = 12;
+ uint32 size;
+ EXPECT_TRUE(GLES2Util::ComputeImageDataSize(
+ kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, 1, &size));
+ EXPECT_EQ(kWidth * kHeight * 4, size);
+ EXPECT_TRUE(GLES2Util::ComputeImageDataSize(
+ kWidth, kHeight, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 1, &size));
+ EXPECT_EQ(kWidth * kHeight * 2, size);
+ EXPECT_TRUE(GLES2Util::ComputeImageDataSize(
+ kWidth, kHeight, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, 1, &size));
+ EXPECT_EQ(kWidth * kHeight * 2, size);
+ EXPECT_TRUE(GLES2Util::ComputeImageDataSize(
+ kWidth, kHeight, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 1, &size));
+ EXPECT_EQ(kWidth * kHeight * 2, size);
+}
+
+TEST_F(GLES2UtilTest, ComputeImageDataSizeUnpackAlignment) {
+ const int kWidth = 19;
+ const int kHeight = 12;
+ uint32 size;
+ EXPECT_TRUE(GLES2Util::ComputeImageDataSize(
+ kWidth, kHeight, GL_RGB, GL_UNSIGNED_BYTE, 1, &size));
+ EXPECT_EQ(kWidth * kHeight * 3, size);
+ EXPECT_TRUE(GLES2Util::ComputeImageDataSize(
+ kWidth, kHeight, GL_RGB, GL_UNSIGNED_BYTE, 2, &size));
+ EXPECT_EQ((kWidth * 3 + 1) * (kHeight - 1) +
+ kWidth * 3, size);
+ EXPECT_TRUE(GLES2Util::ComputeImageDataSize(
+ kWidth, kHeight, GL_RGB, GL_UNSIGNED_BYTE, 4, &size));
+ EXPECT_EQ((kWidth * 3 + 3) * (kHeight - 1) +
+ kWidth * 3, size);
+ EXPECT_TRUE(GLES2Util::ComputeImageDataSize(
+ kWidth, kHeight, GL_RGB, GL_UNSIGNED_BYTE, 8, &size));
+ EXPECT_EQ((kWidth * 3 + 7) * (kHeight - 1) +
+ kWidth * 3, size);
+}
+
+} // namespace gles2
+} // namespace gpu
+
Property changes on: gpu\command_buffer\common\gles2_cmd_utils_unittest.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « gpu/command_buffer/common/gles2_cmd_utils.cc ('k') | gpu/gpu.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698