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