OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/test/layer_tree_pixel_test.h" | 5 #include "cc/test/layer_tree_pixel_test.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "cc/base/switches.h" | 9 #include "cc/base/switches.h" |
10 #include "cc/layers/solid_color_layer.h" | 10 #include "cc/layers/solid_color_layer.h" |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
261 size.width(), | 261 size.width(), |
262 size.height(), | 262 size.height(), |
263 GL_RGBA, | 263 GL_RGBA, |
264 GL_UNSIGNED_BYTE, | 264 GL_UNSIGNED_BYTE, |
265 pixels.get()); | 265 pixels.get()); |
266 | 266 |
267 gl->DeleteFramebuffers(1, &fbo); | 267 gl->DeleteFramebuffers(1, &fbo); |
268 gl->DeleteTextures(1, &texture_id); | 268 gl->DeleteTextures(1, &texture_id); |
269 | 269 |
270 scoped_ptr<SkBitmap> bitmap(new SkBitmap); | 270 scoped_ptr<SkBitmap> bitmap(new SkBitmap); |
271 bitmap->setConfig(SkBitmap::kARGB_8888_Config, | 271 bitmap->allocN32Pixels(size.width(), size.height()); |
272 size.width(), | |
273 size.height()); | |
274 bitmap->allocPixels(); | |
275 | 272 |
276 scoped_ptr<SkAutoLockPixels> lock(new SkAutoLockPixels(*bitmap)); | |
277 uint8* out_pixels = static_cast<uint8*>(bitmap->getPixels()); | 273 uint8* out_pixels = static_cast<uint8*>(bitmap->getPixels()); |
278 | 274 |
279 size_t row_bytes = size.width() * 4; | 275 size_t row_bytes = size.width() * 4; |
280 size_t total_bytes = size.height() * row_bytes; | 276 size_t total_bytes = size.height() * row_bytes; |
281 for (size_t dest_y = 0; dest_y < total_bytes; dest_y += row_bytes) { | 277 for (size_t dest_y = 0; dest_y < total_bytes; dest_y += row_bytes) { |
282 // Flip Y axis. | 278 // Flip Y axis. |
283 size_t src_y = total_bytes - dest_y - row_bytes; | 279 size_t src_y = total_bytes - dest_y - row_bytes; |
284 // Swizzle OpenGL -> Skia byte order. | 280 // Swizzle OpenGL -> Skia byte order. |
285 for (size_t x = 0; x < row_bytes; x += 4) { | 281 for (size_t x = 0; x < row_bytes; x += 4) { |
286 out_pixels[dest_y + x + SK_R32_SHIFT/8] = pixels.get()[src_y + x + 0]; | 282 out_pixels[dest_y + x + SK_R32_SHIFT/8] = pixels.get()[src_y + x + 0]; |
(...skipping 30 matching lines...) Expand all Loading... | |
317 GLES2Interface* gl = context->GetImplementation(); | 313 GLES2Interface* gl = context->GetImplementation(); |
318 | 314 |
319 GLuint texture_id = 0; | 315 GLuint texture_id = 0; |
320 gl->GenTextures(1, &texture_id); | 316 gl->GenTextures(1, &texture_id); |
321 gl->BindTexture(GL_TEXTURE_2D, texture_id); | 317 gl->BindTexture(GL_TEXTURE_2D, texture_id); |
322 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | 318 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
323 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); | 319 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
324 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 320 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
325 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | 321 gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
326 | 322 |
327 DCHECK_EQ(SkBitmap::kARGB_8888_Config, bitmap.getConfig()); | 323 DCHECK_EQ(kPMColor_SkColorType, bitmap.colorType()); |
enne (OOO)
2014/03/18 19:43:03
Is this the same check?
reed1
2014/03/21 20:49:01
Yes. In SkColorType world, we now have two explici
| |
328 | 324 |
329 { | 325 { |
330 SkAutoLockPixels lock(bitmap); | 326 SkAutoLockPixels lock(bitmap); |
331 | 327 |
332 size_t row_bytes = bitmap.width() * 4; | 328 size_t row_bytes = bitmap.width() * 4; |
333 size_t total_bytes = bitmap.height() * row_bytes; | 329 size_t total_bytes = bitmap.height() * row_bytes; |
334 | 330 |
335 scoped_ptr<uint8[]> gl_pixels(new uint8[total_bytes]); | 331 scoped_ptr<uint8[]> gl_pixels(new uint8[total_bytes]); |
336 uint8* bitmap_pixels = static_cast<uint8*>(bitmap.getPixels()); | 332 uint8* bitmap_pixels = static_cast<uint8*>(bitmap.getPixels()); |
337 | 333 |
(...skipping 28 matching lines...) Expand all Loading... | |
366 | 362 |
367 *texture_mailbox = TextureMailbox(mailbox, GL_TEXTURE_2D, sync_point); | 363 *texture_mailbox = TextureMailbox(mailbox, GL_TEXTURE_2D, sync_point); |
368 *release_callback = SingleReleaseCallback::Create( | 364 *release_callback = SingleReleaseCallback::Create( |
369 base::Bind(&LayerTreePixelTest::ReleaseTextureMailbox, | 365 base::Bind(&LayerTreePixelTest::ReleaseTextureMailbox, |
370 base::Unretained(this), | 366 base::Unretained(this), |
371 base::Passed(&context), | 367 base::Passed(&context), |
372 texture_id)); | 368 texture_id)); |
373 } | 369 } |
374 | 370 |
375 } // namespace cc | 371 } // namespace cc |
OLD | NEW |