| 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 <GLES2/gl2.h> | 5 #include <GLES2/gl2.h> |
| 6 #include <GLES2/gl2chromium.h> | 6 #include <GLES2/gl2chromium.h> |
| 7 #include <GLES2/gl2ext.h> | 7 #include <GLES2/gl2ext.h> |
| 8 #include <GLES2/gl2extchromium.h> | 8 #include <GLES2/gl2extchromium.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | 181 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 182 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | 182 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 183 | 183 |
| 184 // Create the gpu memory buffer. | 184 // Create the gpu memory buffer. |
| 185 std::unique_ptr<gfx::GpuMemoryBuffer> buffer(gl_.CreateGpuMemoryBuffer( | 185 std::unique_ptr<gfx::GpuMemoryBuffer> buffer(gl_.CreateGpuMemoryBuffer( |
| 186 gfx::Size(kImageWidth, kImageHeight), GetParam())); | 186 gfx::Size(kImageWidth, kImageHeight), GetParam())); |
| 187 | 187 |
| 188 // Map buffer for writing. | 188 // Map buffer for writing. |
| 189 ASSERT_TRUE(buffer->Map()); | 189 ASSERT_TRUE(buffer->Map()); |
| 190 ASSERT_NE(nullptr, buffer->memory(0)); | 190 ASSERT_NE(nullptr, buffer->memory(0)); |
| 191 ASSERT_NE(0, buffer->stride(0)); | 191 ASSERT_NE(0u, buffer->stride(0)); |
| 192 uint8_t pixel[] = {255u, 0u, 0u, 255u}; | 192 uint8_t pixel[] = {255u, 0u, 0u, 255u}; |
| 193 | 193 |
| 194 // Assign a value to each pixel. | 194 // Assign a value to each pixel. |
| 195 for (int y = 0; y < kImageHeight; ++y) { | 195 for (int y = 0; y < kImageHeight; ++y) { |
| 196 SetRow(GetParam(), | 196 SetRow(GetParam(), |
| 197 static_cast<uint8_t*>(buffer->memory(0)) + y * buffer->stride(0), | 197 static_cast<uint8_t*>(buffer->memory(0)) + y * buffer->stride(0), |
| 198 kImageWidth, pixel); | 198 kImageWidth, pixel); |
| 199 } | 199 } |
| 200 // Unmap the buffer. | 200 // Unmap the buffer. |
| 201 buffer->Unmap(); | 201 buffer->Unmap(); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 INSTANTIATE_TEST_CASE_P(GpuMemoryBufferTests, | 249 INSTANTIATE_TEST_CASE_P(GpuMemoryBufferTests, |
| 250 GpuMemoryBufferTest, | 250 GpuMemoryBufferTest, |
| 251 ::testing::Values(gfx::BufferFormat::R_8, | 251 ::testing::Values(gfx::BufferFormat::R_8, |
| 252 gfx::BufferFormat::BGR_565, | 252 gfx::BufferFormat::BGR_565, |
| 253 gfx::BufferFormat::RGBA_4444, | 253 gfx::BufferFormat::RGBA_4444, |
| 254 gfx::BufferFormat::RGBA_8888, | 254 gfx::BufferFormat::RGBA_8888, |
| 255 gfx::BufferFormat::BGRA_8888)); | 255 gfx::BufferFormat::BGRA_8888)); |
| 256 | 256 |
| 257 } // namespace gles2 | 257 } // namespace gles2 |
| 258 } // namespace gpu | 258 } // namespace gpu |
| OLD | NEW |