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

Unified Diff: client/deps/glbench/src/readpixeltest.cc

Issue 2123013: Split tests into individual files. Got rid of globals by converting them to classes. (Closed) Base URL: ssh://git@chromiumos-git//autotest.git
Patch Set: addressed comments Created 10 years, 7 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 | « client/deps/glbench/src/main.cc ('k') | client/deps/glbench/src/shaders.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/deps/glbench/src/readpixeltest.cc
diff --git a/client/deps/glbench/src/readpixeltest.cc b/client/deps/glbench/src/readpixeltest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..4d6d42029b4531a637cc8eaacaf9aef61b3d883f
--- /dev/null
+++ b/client/deps/glbench/src/readpixeltest.cc
@@ -0,0 +1,64 @@
+// Copyright (c) 2010 The Chromium OS 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 "base/logging.h"
+#include "base/scoped_ptr.h"
+
+#include "main.h"
+#include "testbase.h"
+
+
+namespace glbench {
+
+
+class ReadPixelTest : public TestBase {
+ public:
+ ReadPixelTest() : pixels_(NULL) {}
+ virtual ~ReadPixelTest() {}
+ virtual bool TestFunc(int iter);
+ virtual bool Run();
+
+ private:
+ void* pixels_;
+ DISALLOW_COPY_AND_ASSIGN(ReadPixelTest);
+};
+
+
+bool ReadPixelTest::TestFunc(int iter) {
+ glReadPixels(0, 0, g_width, g_height, GL_RGBA, GL_UNSIGNED_BYTE, pixels_);
+ CHECK(glGetError() == 0);
+ for (int i = 0; i < iter; i++)
+ glReadPixels(0, 0, g_width, g_height, GL_RGBA, GL_UNSIGNED_BYTE, pixels_);
+ return true;
+}
+
+
+bool ReadPixelTest::Run() {
+ // One GL_RGBA pixel takes 4 bytes.
+ const int row_size = g_width * 4;
+ // Default GL_PACK_ALIGNMENT is 4, round up pixel row size to multiple of 4.
+ // This is a no-op because row_size is already divisible by 4.
+ // One is added so that we can test reads into unaligned location.
+ scoped_array<char> buf(new char[((row_size + 3) & ~3) * g_height + 1]);
+ pixels_ = buf.get();
+ RunTest(this, "mpixels_sec_pixel_read", g_width * g_height, true);
+
+ // Reducing GL_PACK_ALIGNMENT can only make rows smaller. No need to
+ // reallocate the buffer.
+ glPixelStorei(GL_PACK_ALIGNMENT, 1);
+ RunTest(this, "mpixels_sec_pixel_read_2", g_width * g_height, true);
+
+ pixels_ = static_cast<void*>(buf.get() + 1);
+ RunTest(this, "mpixels_sec_pixel_read_3", g_width * g_height, true);
+
+ return true;
+}
+
+
+TestBase* GetReadPixelTest() {
+ return new ReadPixelTest;
+}
+
+
+} // namespace glbench
« no previous file with comments | « client/deps/glbench/src/main.cc ('k') | client/deps/glbench/src/shaders.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698