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

Side by Side Diff: ui/gfx/codec/png_codec.cc

Issue 2823003002: SkBitmap and SkPixelRef no longer need lock/unlock (Closed)
Patch Set: win fix after rebase 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
« no previous file with comments | « ui/gfx/codec/png_codec.h ('k') | ui/gfx/color_analysis.cc » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/gfx/codec/png_codec.h" 5 #include "ui/gfx/codec/png_codec.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 724
725 bool InternalEncodeSkBitmap(const SkBitmap& input, 725 bool InternalEncodeSkBitmap(const SkBitmap& input,
726 bool discard_transparency, 726 bool discard_transparency,
727 int compression_level, 727 int compression_level,
728 std::vector<unsigned char>* output) { 728 std::vector<unsigned char>* output) {
729 if (input.empty() || input.isNull()) 729 if (input.empty() || input.isNull())
730 return false; 730 return false;
731 int bpp = input.bytesPerPixel(); 731 int bpp = input.bytesPerPixel();
732 DCHECK(bpp == 1 || bpp == 4); // We support kA8_Config and kARGB_8888_Config. 732 DCHECK(bpp == 1 || bpp == 4); // We support kA8_Config and kARGB_8888_Config.
733 733
734 SkAutoLockPixels lock_input(input);
735 unsigned char* inputAddr = bpp == 1 ? 734 unsigned char* inputAddr = bpp == 1 ?
736 reinterpret_cast<unsigned char*>(input.getAddr8(0, 0)) : 735 reinterpret_cast<unsigned char*>(input.getAddr8(0, 0)) :
737 reinterpret_cast<unsigned char*>(input.getAddr32(0, 0)); // bpp = 4 736 reinterpret_cast<unsigned char*>(input.getAddr32(0, 0)); // bpp = 4
738 return EncodeWithCompressionLevel( 737 return EncodeWithCompressionLevel(
739 inputAddr, 738 inputAddr,
740 PNGCodec::FORMAT_SkBitmap, 739 PNGCodec::FORMAT_SkBitmap,
741 Size(input.width(), input.height()), 740 Size(input.width(), input.height()),
742 static_cast<int>(input.rowBytes()), 741 static_cast<int>(input.rowBytes()),
743 discard_transparency, 742 discard_transparency,
744 std::vector<PNGCodec::Comment>(), 743 std::vector<PNGCodec::Comment>(),
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 } 796 }
798 797
799 PNGCodec::Comment::Comment(const std::string& k, const std::string& t) 798 PNGCodec::Comment::Comment(const std::string& k, const std::string& t)
800 : key(k), text(t) { 799 : key(k), text(t) {
801 } 800 }
802 801
803 PNGCodec::Comment::~Comment() { 802 PNGCodec::Comment::~Comment() {
804 } 803 }
805 804
806 } // namespace gfx 805 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/codec/png_codec.h ('k') | ui/gfx/color_analysis.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698