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

Side by Side Diff: cc/test/layer_tree_pixel_test.cc

Issue 1539203002: Switch to standard integer types in cc/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more includes Created 5 years 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
« no previous file with comments | « cc/test/layer_tree_json_parser_unittest.cc ('k') | cc/test/mock_occlusion_tracker.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stddef.h>
8 #include <stdint.h>
9
7 #include "base/command_line.h" 10 #include "base/command_line.h"
8 #include "base/path_service.h" 11 #include "base/path_service.h"
9 #include "cc/base/switches.h" 12 #include "cc/base/switches.h"
10 #include "cc/layers/solid_color_layer.h" 13 #include "cc/layers/solid_color_layer.h"
11 #include "cc/layers/texture_layer.h" 14 #include "cc/layers/texture_layer.h"
12 #include "cc/output/copy_output_request.h" 15 #include "cc/output/copy_output_request.h"
13 #include "cc/output/copy_output_result.h" 16 #include "cc/output/copy_output_result.h"
14 #include "cc/output/direct_renderer.h" 17 #include "cc/output/direct_renderer.h"
15 #include "cc/resources/texture_mailbox.h" 18 #include "cc/resources/texture_mailbox.h"
16 #include "cc/test/paths.h" 19 #include "cc/test/paths.h"
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 gl->BindTexture(GL_TEXTURE_2D, 0); 228 gl->BindTexture(GL_TEXTURE_2D, 0);
226 229
227 GLuint fbo = 0; 230 GLuint fbo = 0;
228 gl->GenFramebuffers(1, &fbo); 231 gl->GenFramebuffers(1, &fbo);
229 gl->BindFramebuffer(GL_FRAMEBUFFER, fbo); 232 gl->BindFramebuffer(GL_FRAMEBUFFER, fbo);
230 gl->FramebufferTexture2D( 233 gl->FramebufferTexture2D(
231 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture_id, 0); 234 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture_id, 0);
232 EXPECT_EQ(static_cast<unsigned>(GL_FRAMEBUFFER_COMPLETE), 235 EXPECT_EQ(static_cast<unsigned>(GL_FRAMEBUFFER_COMPLETE),
233 gl->CheckFramebufferStatus(GL_FRAMEBUFFER)); 236 gl->CheckFramebufferStatus(GL_FRAMEBUFFER));
234 237
235 scoped_ptr<uint8[]> pixels(new uint8[size.GetArea() * 4]); 238 scoped_ptr<uint8_t[]> pixels(new uint8_t[size.GetArea() * 4]);
236 gl->ReadPixels(0, 239 gl->ReadPixels(0,
237 0, 240 0,
238 size.width(), 241 size.width(),
239 size.height(), 242 size.height(),
240 GL_RGBA, 243 GL_RGBA,
241 GL_UNSIGNED_BYTE, 244 GL_UNSIGNED_BYTE,
242 pixels.get()); 245 pixels.get());
243 246
244 gl->DeleteFramebuffers(1, &fbo); 247 gl->DeleteFramebuffers(1, &fbo);
245 gl->DeleteTextures(1, &texture_id); 248 gl->DeleteTextures(1, &texture_id);
246 249
247 scoped_ptr<SkBitmap> bitmap(new SkBitmap); 250 scoped_ptr<SkBitmap> bitmap(new SkBitmap);
248 bitmap->allocN32Pixels(size.width(), size.height()); 251 bitmap->allocN32Pixels(size.width(), size.height());
249 252
250 uint8* out_pixels = static_cast<uint8*>(bitmap->getPixels()); 253 uint8_t* out_pixels = static_cast<uint8_t*>(bitmap->getPixels());
251 254
252 size_t row_bytes = size.width() * 4; 255 size_t row_bytes = size.width() * 4;
253 size_t total_bytes = size.height() * row_bytes; 256 size_t total_bytes = size.height() * row_bytes;
254 for (size_t dest_y = 0; dest_y < total_bytes; dest_y += row_bytes) { 257 for (size_t dest_y = 0; dest_y < total_bytes; dest_y += row_bytes) {
255 // Flip Y axis. 258 // Flip Y axis.
256 size_t src_y = total_bytes - dest_y - row_bytes; 259 size_t src_y = total_bytes - dest_y - row_bytes;
257 // Swizzle OpenGL -> Skia byte order. 260 // Swizzle OpenGL -> Skia byte order.
258 for (size_t x = 0; x < row_bytes; x += 4) { 261 for (size_t x = 0; x < row_bytes; x += 4) {
259 out_pixels[dest_y + x + SK_R32_SHIFT/8] = pixels.get()[src_y + x + 0]; 262 out_pixels[dest_y + x + SK_R32_SHIFT/8] = pixels.get()[src_y + x + 0];
260 out_pixels[dest_y + x + SK_G32_SHIFT/8] = pixels.get()[src_y + x + 1]; 263 out_pixels[dest_y + x + SK_G32_SHIFT/8] = pixels.get()[src_y + x + 1];
261 out_pixels[dest_y + x + SK_B32_SHIFT/8] = pixels.get()[src_y + x + 2]; 264 out_pixels[dest_y + x + SK_B32_SHIFT/8] = pixels.get()[src_y + x + 2];
262 out_pixels[dest_y + x + SK_A32_SHIFT/8] = pixels.get()[src_y + x + 3]; 265 out_pixels[dest_y + x + SK_A32_SHIFT/8] = pixels.get()[src_y + x + 3];
263 } 266 }
264 } 267 }
265 268
266 return bitmap; 269 return bitmap;
267 } 270 }
268 271
269 void LayerTreePixelTest::Finish() { 272 void LayerTreePixelTest::Finish() {
270 scoped_ptr<gpu::GLInProcessContext> context = CreateTestInProcessContext(); 273 scoped_ptr<gpu::GLInProcessContext> context = CreateTestInProcessContext();
271 GLES2Interface* gl = context->GetImplementation(); 274 GLES2Interface* gl = context->GetImplementation();
272 gl->Finish(); 275 gl->Finish();
273 } 276 }
274 277
275 } // namespace cc 278 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/layer_tree_json_parser_unittest.cc ('k') | cc/test/mock_occlusion_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698