OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/resources/texture_uploader.h" | 5 #include "cc/resources/texture_uploader.h" |
6 | 6 |
7 #include "cc/base/util.h" | 7 #include "cc/base/util.h" |
8 #include "cc/resources/prioritized_resource.h" | 8 #include "cc/resources/prioritized_resource.h" |
9 #include "gpu/command_buffer/client/gles2_interface_stub.h" | 9 #include "gpu/command_buffer/client/gles2_interface_stub.h" |
10 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 #include "third_party/khronos/GLES2/gl2.h" | 12 #include "third_party/khronos/GLES2/gl2.h" |
13 #include "third_party/khronos/GLES2/gl2ext.h" | 13 #include "third_party/khronos/GLES2/gl2ext.h" |
14 | 14 |
15 namespace cc { | 15 namespace cc { |
16 namespace { | 16 namespace { |
17 | 17 |
18 class TextureUploadTestContext : public gpu::gles2::GLES2InterfaceStub { | 18 class TextureUploadTestContext : public gpu::gles2::GLES2InterfaceStub { |
19 public: | 19 public: |
20 TextureUploadTestContext() : result_available_(0), unpack_alignment_(4) {} | 20 TextureUploadTestContext() : result_available_(0), unpack_alignment_(4) {} |
21 | 21 |
22 virtual void PixelStorei(GLenum pname, GLint param) OVERRIDE { | 22 virtual void PixelStorei(GLenum pname, GLint param) override { |
23 switch (pname) { | 23 switch (pname) { |
24 case GL_UNPACK_ALIGNMENT: | 24 case GL_UNPACK_ALIGNMENT: |
25 // Param should be a power of two <= 8. | 25 // Param should be a power of two <= 8. |
26 EXPECT_EQ(0, param & (param - 1)); | 26 EXPECT_EQ(0, param & (param - 1)); |
27 EXPECT_GE(8, param); | 27 EXPECT_GE(8, param); |
28 switch (param) { | 28 switch (param) { |
29 case 1: | 29 case 1: |
30 case 2: | 30 case 2: |
31 case 4: | 31 case 4: |
32 case 8: | 32 case 8: |
33 unpack_alignment_ = param; | 33 unpack_alignment_ = param; |
34 break; | 34 break; |
35 default: | 35 default: |
36 break; | 36 break; |
37 } | 37 } |
38 break; | 38 break; |
39 default: | 39 default: |
40 break; | 40 break; |
41 } | 41 } |
42 } | 42 } |
43 | 43 |
44 virtual void GetQueryObjectuivEXT(GLuint, | 44 virtual void GetQueryObjectuivEXT(GLuint, |
45 GLenum type, | 45 GLenum type, |
46 GLuint* value) OVERRIDE { | 46 GLuint* value) override { |
47 switch (type) { | 47 switch (type) { |
48 case GL_QUERY_RESULT_AVAILABLE_EXT: | 48 case GL_QUERY_RESULT_AVAILABLE_EXT: |
49 *value = result_available_; | 49 *value = result_available_; |
50 break; | 50 break; |
51 default: | 51 default: |
52 *value = 0; | 52 *value = 0; |
53 break; | 53 break; |
54 } | 54 } |
55 } | 55 } |
56 | 56 |
57 virtual void TexSubImage2D(GLenum target, | 57 virtual void TexSubImage2D(GLenum target, |
58 GLint level, | 58 GLint level, |
59 GLint xoffset, | 59 GLint xoffset, |
60 GLint yoffset, | 60 GLint yoffset, |
61 GLsizei width, | 61 GLsizei width, |
62 GLsizei height, | 62 GLsizei height, |
63 GLenum format, | 63 GLenum format, |
64 GLenum type, | 64 GLenum type, |
65 const void* pixels) OVERRIDE { | 65 const void* pixels) override { |
66 EXPECT_EQ(static_cast<unsigned>(GL_TEXTURE_2D), target); | 66 EXPECT_EQ(static_cast<unsigned>(GL_TEXTURE_2D), target); |
67 EXPECT_EQ(0, level); | 67 EXPECT_EQ(0, level); |
68 EXPECT_LE(0, width); | 68 EXPECT_LE(0, width); |
69 EXPECT_LE(0, height); | 69 EXPECT_LE(0, height); |
70 EXPECT_LE(0, xoffset); | 70 EXPECT_LE(0, xoffset); |
71 EXPECT_LE(0, yoffset); | 71 EXPECT_LE(0, yoffset); |
72 EXPECT_LE(0, width); | 72 EXPECT_LE(0, width); |
73 EXPECT_LE(0, height); | 73 EXPECT_LE(0, height); |
74 | 74 |
75 // Check for allowed format/type combination. | 75 // Check for allowed format/type combination. |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 for (int i = 0; i < 86; ++i) { | 231 for (int i = 0; i < 86; ++i) { |
232 // Mark the beginning and end of each row, for the test. | 232 // Mark the beginning and end of each row, for the test. |
233 buffer[i * 1 * 82] = 0x1; | 233 buffer[i * 1 * 82] = 0x1; |
234 buffer[(i + 1) * 82 - 1] = 0x2; | 234 buffer[(i + 1) * 82 - 1] = 0x2; |
235 } | 235 } |
236 UploadTexture(uploader.get(), LUMINANCE_8, gfx::Size(82, 86), buffer); | 236 UploadTexture(uploader.get(), LUMINANCE_8, gfx::Size(82, 86), buffer); |
237 } | 237 } |
238 | 238 |
239 } // namespace | 239 } // namespace |
240 } // namespace cc | 240 } // namespace cc |
OLD | NEW |