Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(506)

Side by Side Diff: gpu/command_buffer/tests/gl_gpu_memory_buffer_unittest.cc

Issue 1024113003: Add multi-planar functions to GpuMemoryBuffer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: reveman@ comments. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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()];
reveman 2015/03/24 20:13:59 gfx::GpuMemoryBuffer::RGBA_8888 implies 1 plane. Y
emircan 2015/03/24 21:43:44 Done.
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698