| 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" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 } | 104 } |
| 105 break; | 105 break; |
| 106 case GL_LUMINANCE: | 106 case GL_LUMINANCE: |
| 107 EXPECT_EQ(static_cast<unsigned>(GL_UNSIGNED_BYTE), type); | 107 EXPECT_EQ(static_cast<unsigned>(GL_UNSIGNED_BYTE), type); |
| 108 bytes_per_pixel = 1; | 108 bytes_per_pixel = 1; |
| 109 break; | 109 break; |
| 110 case GL_LUMINANCE_ALPHA: | 110 case GL_LUMINANCE_ALPHA: |
| 111 EXPECT_EQ(static_cast<unsigned>(GL_UNSIGNED_BYTE), type); | 111 EXPECT_EQ(static_cast<unsigned>(GL_UNSIGNED_BYTE), type); |
| 112 bytes_per_pixel = 2; | 112 bytes_per_pixel = 2; |
| 113 break; | 113 break; |
| 114 case GL_RED_EXT: | |
| 115 EXPECT_EQ(static_cast<unsigned>(GL_UNSIGNED_BYTE), type); | |
| 116 bytes_per_pixel = 1; | |
| 117 break; | |
| 118 case GL_RG_EXT: | |
| 119 EXPECT_EQ(static_cast<unsigned>(GL_UNSIGNED_BYTE), type); | |
| 120 bytes_per_pixel = 2; | |
| 121 break; | |
| 122 } | 114 } |
| 123 | 115 |
| 124 // If NULL, we aren't checking texture contents. | 116 // If NULL, we aren't checking texture contents. |
| 125 if (pixels == NULL) | 117 if (pixels == NULL) |
| 126 return; | 118 return; |
| 127 | 119 |
| 128 const uint8* bytes = static_cast<const uint8*>(pixels); | 120 const uint8* bytes = static_cast<const uint8*>(pixels); |
| 129 // We'll expect the first byte of every row to be 0x1, and the last byte to | 121 // We'll expect the first byte of every row to be 0x1, and the last byte to |
| 130 // be 0x2. | 122 // be 0x2. |
| 131 const unsigned int stride = | 123 const unsigned int stride = |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 UploadTexture(uploader.get(), ALPHA_8, gfx::Size(41, 86), buffer); | 225 UploadTexture(uploader.get(), ALPHA_8, gfx::Size(41, 86), buffer); |
| 234 | 226 |
| 235 // Upload a tightly packed 82x86 LUMINANCE texture. | 227 // Upload a tightly packed 82x86 LUMINANCE texture. |
| 236 memset(buffer, 0, sizeof(buffer)); | 228 memset(buffer, 0, sizeof(buffer)); |
| 237 for (int i = 0; i < 86; ++i) { | 229 for (int i = 0; i < 86; ++i) { |
| 238 // Mark the beginning and end of each row, for the test. | 230 // Mark the beginning and end of each row, for the test. |
| 239 buffer[i * 1 * 82] = 0x1; | 231 buffer[i * 1 * 82] = 0x1; |
| 240 buffer[(i + 1) * 82 - 1] = 0x2; | 232 buffer[(i + 1) * 82 - 1] = 0x2; |
| 241 } | 233 } |
| 242 UploadTexture(uploader.get(), LUMINANCE_8, gfx::Size(82, 86), buffer); | 234 UploadTexture(uploader.get(), LUMINANCE_8, gfx::Size(82, 86), buffer); |
| 243 | |
| 244 // Upload a tightly packed 82x86 RED texture. | |
| 245 memset(buffer, 0, sizeof(buffer)); | |
| 246 for (int i = 0; i < 86; ++i) { | |
| 247 // Mark the beginning and end of each row, for the test. | |
| 248 buffer[i * 1 * 82] = 0x1; | |
| 249 buffer[(i + 1) * 82 - 1] = 0x2; | |
| 250 } | |
| 251 UploadTexture(uploader.get(), RED_8, gfx::Size(82, 86), buffer); | |
| 252 } | 235 } |
| 253 | 236 |
| 254 } // namespace | 237 } // namespace |
| 255 } // namespace cc | 238 } // namespace cc |
| OLD | NEW |