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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/logging.h"
6 #include "base/scoped_ptr.h"
7
8 #include "main.h"
9 #include "testbase.h"
10
11
12 namespace glbench {
13
14
15 class ReadPixelTest : public TestBase {
16 public:
17 ReadPixelTest() : pixels_(NULL) {}
18 virtual ~ReadPixelTest() {}
19 virtual bool TestFunc(int iter);
20 virtual bool Run();
21
22 private:
23 void* pixels_;
24 DISALLOW_COPY_AND_ASSIGN(ReadPixelTest);
25 };
26
27
28 bool ReadPixelTest::TestFunc(int iter) {
29 glReadPixels(0, 0, g_width, g_height, GL_RGBA, GL_UNSIGNED_BYTE, pixels_);
30 CHECK(glGetError() == 0);
31 for (int i = 0; i < iter; i++)
32 glReadPixels(0, 0, g_width, g_height, GL_RGBA, GL_UNSIGNED_BYTE, pixels_);
33 return true;
34 }
35
36
37 bool ReadPixelTest::Run() {
38 // One GL_RGBA pixel takes 4 bytes.
39 const int row_size = g_width * 4;
40 // Default GL_PACK_ALIGNMENT is 4, round up pixel row size to multiple of 4.
41 // This is a no-op because row_size is already divisible by 4.
42 // One is added so that we can test reads into unaligned location.
43 scoped_array<char> buf(new char[((row_size + 3) & ~3) * g_height + 1]);
44 pixels_ = buf.get();
45 RunTest(this, "mpixels_sec_pixel_read", g_width * g_height, true);
46
47 // Reducing GL_PACK_ALIGNMENT can only make rows smaller. No need to
48 // reallocate the buffer.
49 glPixelStorei(GL_PACK_ALIGNMENT, 1);
50 RunTest(this, "mpixels_sec_pixel_read_2", g_width * g_height, true);
51
52 pixels_ = static_cast<void*>(buf.get() + 1);
53 RunTest(this, "mpixels_sec_pixel_read_3", g_width * g_height, true);
54
55 return true;
56 }
57
58
59 TestBase* GetReadPixelTest() {
60 return new ReadPixelTest;
61 }
62
63
64 } // namespace glbench
OLDNEW
« 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