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

Side by Side Diff: cc/output/gl_renderer.cc

Issue 2823003002: SkBitmap and SkPixelRef no longer need lock/unlock (Closed)
Patch Set: fix mac Created 3 years, 8 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 2010 The Chromium Authors. All rights reserved. 1 // Copyright 2010 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/output/gl_renderer.h" 5 #include "cc/output/gl_renderer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 2807 matching lines...) Expand 10 before | Expand all | Expand 10 after
2818 std::unique_ptr<SkBitmap> bitmap; 2818 std::unique_ptr<SkBitmap> bitmap;
2819 2819
2820 if (source_buffer != 0) { 2820 if (source_buffer != 0) {
2821 gl_->BindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, source_buffer); 2821 gl_->BindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, source_buffer);
2822 src_pixels = static_cast<uint8_t*>(gl_->MapBufferCHROMIUM( 2822 src_pixels = static_cast<uint8_t*>(gl_->MapBufferCHROMIUM(
2823 GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, GL_READ_ONLY)); 2823 GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, GL_READ_ONLY));
2824 2824
2825 if (src_pixels) { 2825 if (src_pixels) {
2826 bitmap.reset(new SkBitmap); 2826 bitmap.reset(new SkBitmap);
2827 bitmap->allocN32Pixels(size.width(), size.height()); 2827 bitmap->allocN32Pixels(size.width(), size.height());
2828 std::unique_ptr<SkAutoLockPixels> lock(new SkAutoLockPixels(*bitmap));
2829 uint8_t* dest_pixels = static_cast<uint8_t*>(bitmap->getPixels()); 2828 uint8_t* dest_pixels = static_cast<uint8_t*>(bitmap->getPixels());
2830 2829
2831 size_t row_bytes = size.width() * 4; 2830 size_t row_bytes = size.width() * 4;
2832 int num_rows = size.height(); 2831 int num_rows = size.height();
2833 size_t total_bytes = num_rows * row_bytes; 2832 size_t total_bytes = num_rows * row_bytes;
2834 for (size_t dest_y = 0; dest_y < total_bytes; dest_y += row_bytes) { 2833 for (size_t dest_y = 0; dest_y < total_bytes; dest_y += row_bytes) {
2835 // Flip Y axis. 2834 // Flip Y axis.
2836 size_t src_y = total_bytes - dest_y - row_bytes; 2835 size_t src_y = total_bytes - dest_y - row_bytes;
2837 // Swizzle OpenGL -> Skia byte order. 2836 // Swizzle OpenGL -> Skia byte order.
2838 for (size_t x = 0; x < row_bytes; x += 4) { 2837 for (size_t x = 0; x < row_bytes; x += 4) {
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after
3596 return; 3595 return;
3597 3596
3598 // Report GPU overdraw as a percentage of |max_result|. 3597 // Report GPU overdraw as a percentage of |max_result|.
3599 TRACE_COUNTER1( 3598 TRACE_COUNTER1(
3600 TRACE_DISABLED_BY_DEFAULT("cc.debug.overdraw"), "GPU Overdraw", 3599 TRACE_DISABLED_BY_DEFAULT("cc.debug.overdraw"), "GPU Overdraw",
3601 (std::accumulate(overdraw->begin(), overdraw->end(), 0) * 100) / 3600 (std::accumulate(overdraw->begin(), overdraw->end(), 0) * 100) /
3602 max_result); 3601 max_result);
3603 } 3602 }
3604 3603
3605 } // namespace cc 3604 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698