| 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 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 // An end to end test that tests the whole GpuMemoryBuffer lifecycle. | 73 // An end to end test that tests the whole GpuMemoryBuffer lifecycle. |
| 74 TEST_F(GpuMemoryBufferTest, Lifecycle) { | 74 TEST_F(GpuMemoryBufferTest, Lifecycle) { |
| 75 uint8 pixels[1 * 4] = { 255u, 0u, 0u, 255u }; | 75 uint8 pixels[1 * 4] = { 255u, 0u, 0u, 255u }; |
| 76 | 76 |
| 77 scoped_ptr<gfx::GpuMemoryBuffer> buffer(gl_.CreateGpuMemoryBuffer( | 77 scoped_ptr<gfx::GpuMemoryBuffer> buffer(gl_.CreateGpuMemoryBuffer( |
| 78 gfx::Size(kImageWidth, kImageHeight), gfx::GpuMemoryBuffer::RGBA_8888)); | 78 gfx::Size(kImageWidth, kImageHeight), gfx::GpuMemoryBuffer::RGBA_8888)); |
| 79 | 79 |
| 80 // Map buffer for writing. | 80 // Map buffer for writing. |
| 81 uint8* mapped_buffer = static_cast<uint8*>(buffer->Map()); | 81 void* mapped_buffers[buffer->GetNumberOfPlanes()]; |
| 82 bool map_completed = buffer->Map(mapped_buffers); |
| 83 DCHECK(map_completed); |
| 84 |
| 85 uint8* mapped_buffer = static_cast<uint8*>(mapped_buffers[0]); |
| 82 ASSERT_TRUE(mapped_buffer != NULL); | 86 ASSERT_TRUE(mapped_buffer != NULL); |
| 83 | 87 |
| 84 // Assign a value to each pixel. | 88 // Assign a value to each pixel. |
| 85 int stride = kImageWidth * kImageBytesPerPixel; | 89 int stride = kImageWidth * kImageBytesPerPixel; |
| 86 for (int x = 0; x < kImageWidth; ++x) { | 90 for (int x = 0; x < kImageWidth; ++x) { |
| 87 for (int y = 0; y < kImageHeight; ++y) { | 91 for (int y = 0; y < kImageHeight; ++y) { |
| 88 mapped_buffer[y * stride + x * kImageBytesPerPixel + 0] = pixels[0]; | 92 mapped_buffer[y * stride + x * kImageBytesPerPixel + 0] = pixels[0]; |
| 89 mapped_buffer[y * stride + x * kImageBytesPerPixel + 1] = pixels[1]; | 93 mapped_buffer[y * stride + x * kImageBytesPerPixel + 1] = pixels[1]; |
| 90 mapped_buffer[y * stride + x * kImageBytesPerPixel + 2] = pixels[2]; | 94 mapped_buffer[y * stride + x * kImageBytesPerPixel + 2] = pixels[2]; |
| 91 mapped_buffer[y * stride + x * kImageBytesPerPixel + 3] = pixels[3]; | 95 mapped_buffer[y * stride + x * kImageBytesPerPixel + 3] = pixels[3]; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 119 | 123 |
| 120 // Release the image. | 124 // Release the image. |
| 121 glReleaseTexImage2DCHROMIUM(GL_TEXTURE_2D, image_id); | 125 glReleaseTexImage2DCHROMIUM(GL_TEXTURE_2D, image_id); |
| 122 | 126 |
| 123 // Destroy the image. | 127 // Destroy the image. |
| 124 glDestroyImageCHROMIUM(image_id); | 128 glDestroyImageCHROMIUM(image_id); |
| 125 } | 129 } |
| 126 | 130 |
| 127 } // namespace gles2 | 131 } // namespace gles2 |
| 128 } // namespace gpu | 132 } // namespace gpu |
| OLD | NEW |