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

Side by Side Diff: printing/image.cc

Issue 6544028: Create a Factory for NativeMetafile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed styling issues (naming, 80cols) Created 9 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "printing/image.h" 5 #include "printing/image.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/md5.h" 8 #include "base/md5.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "printing/metafile_factory.h"
11 #include "base/scoped_ptr.h"
10 #include "third_party/skia/include/core/SkColor.h" 12 #include "third_party/skia/include/core/SkColor.h"
11 #include "ui/gfx/codec/png_codec.h" 13 #include "ui/gfx/codec/png_codec.h"
12 14
13 namespace printing { 15 namespace printing {
14 16
15 Image::Image(const FilePath& path) 17 Image::Image(const FilePath& path)
16 : row_length_(0), 18 : row_length_(0),
17 ignore_alpha_(true) { 19 ignore_alpha_(true) {
18 std::string data; 20 std::string data;
19 file_util::ReadFileToString(path, &data); 21 file_util::ReadFileToString(path, &data);
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 bool success = gfx::PNGCodec::Decode( 139 bool success = gfx::PNGCodec::Decode(
138 reinterpret_cast<const unsigned char*>(compressed.c_str()), 140 reinterpret_cast<const unsigned char*>(compressed.c_str()),
139 compressed.size(), gfx::PNGCodec::FORMAT_BGRA, &data_, &w, &h); 141 compressed.size(), gfx::PNGCodec::FORMAT_BGRA, &data_, &w, &h);
140 size_.SetSize(w, h); 142 size_.SetSize(w, h);
141 row_length_ = size_.width() * sizeof(uint32); 143 row_length_ = size_.width() * sizeof(uint32);
142 return success; 144 return success;
143 } 145 }
144 146
145 bool Image::LoadMetafile(const std::string& data) { 147 bool Image::LoadMetafile(const std::string& data) {
146 DCHECK(!data.empty()); 148 DCHECK(!data.empty());
147 NativeMetafile metafile; 149 scoped_ptr<NativeMetafile> metafile(
148 metafile.Init(data.data(), data.size()); 150 printing::MetafileFactory::GetMetafile());
149 return LoadMetafile(metafile); 151 metafile->Init(data.data(), data.size());
152 return LoadMetafile(*metafile.get());
150 } 153 }
151 154
152 } // namespace printing 155 } // namespace printing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698