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

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

Issue 1412223009: Reland: GpuMemoryBuffer interface change: Map(**) to Map() and memory(plane); stride(plane) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Win X64 compile fix Created 5 years, 1 month 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 163 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
164 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 164 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
165 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 165 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
166 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 166 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
167 167
168 // Create the gpu memory buffer. 168 // Create the gpu memory buffer.
169 scoped_ptr<gfx::GpuMemoryBuffer> buffer(gl_.CreateGpuMemoryBuffer( 169 scoped_ptr<gfx::GpuMemoryBuffer> buffer(gl_.CreateGpuMemoryBuffer(
170 gfx::Size(kImageWidth, kImageHeight), GetParam())); 170 gfx::Size(kImageWidth, kImageHeight), GetParam()));
171 171
172 // Map buffer for writing. 172 // Map buffer for writing.
173 void* data; 173 ASSERT_TRUE(buffer->Map());
174 bool rv = buffer->Map(&data); 174 ASSERT_NE(nullptr, buffer->memory(0));
175 DCHECK(rv); 175 ASSERT_NE(0, buffer->stride(0));
176
177 uint8_t* mapped_buffer = static_cast<uint8_t*>(data);
178 ASSERT_TRUE(mapped_buffer != NULL);
179
180 uint8_t pixel[] = {255u, 0u, 0u, 255u}; 176 uint8_t pixel[] = {255u, 0u, 0u, 255u};
181 177
182 // Assign a value to each pixel. 178 // Assign a value to each pixel.
183 int stride = 0; 179 for (int y = 0; y < kImageHeight; ++y) {
184 buffer->GetStride(&stride); 180 SetRow(GetParam(),
185 ASSERT_NE(stride, 0); 181 static_cast<uint8_t*>(buffer->memory(0)) + y * buffer->stride(0),
186 for (int y = 0; y < kImageHeight; ++y) 182 kImageWidth, pixel);
187 SetRow(GetParam(), mapped_buffer + y * stride, kImageWidth, pixel); 183 }
188
189 // Unmap the buffer. 184 // Unmap the buffer.
190 buffer->Unmap(); 185 buffer->Unmap();
191 186
192 // Create the image. This should add the image ID to the ImageManager. 187 // Create the image. This should add the image ID to the ImageManager.
193 GLuint image_id = 188 GLuint image_id =
194 glCreateImageCHROMIUM(buffer->AsClientBuffer(), kImageWidth, kImageHeight, 189 glCreateImageCHROMIUM(buffer->AsClientBuffer(), kImageWidth, kImageHeight,
195 InternalFormat(GetParam())); 190 InternalFormat(GetParam()));
196 ASSERT_NE(0u, image_id); 191 ASSERT_NE(0u, image_id);
197 ASSERT_TRUE(gl_.decoder()->GetImageManager()->LookupImage(image_id) != NULL); 192 ASSERT_TRUE(gl_.decoder()->GetImageManager()->LookupImage(image_id) != NULL);
198 193
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 232
238 INSTANTIATE_TEST_CASE_P(GpuMemoryBufferTests, 233 INSTANTIATE_TEST_CASE_P(GpuMemoryBufferTests,
239 GpuMemoryBufferTest, 234 GpuMemoryBufferTest,
240 ::testing::Values(gfx::BufferFormat::R_8, 235 ::testing::Values(gfx::BufferFormat::R_8,
241 gfx::BufferFormat::RGBA_4444, 236 gfx::BufferFormat::RGBA_4444,
242 gfx::BufferFormat::RGBA_8888, 237 gfx::BufferFormat::RGBA_8888,
243 gfx::BufferFormat::BGRA_8888)); 238 gfx::BufferFormat::BGRA_8888));
244 239
245 } // namespace gles2 240 } // namespace gles2
246 } // namespace gpu 241 } // namespace gpu
OLDNEW
« no previous file with comments | « content/test/gpu_memory_buffer_impl_test_template.h ('k') | gpu/command_buffer/tests/gl_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698