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

Side by Side Diff: printing/image_mac.cc

Issue 2812263002: clean up printing::Image and printing::Metafile (Closed)
Patch Set: return 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 (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 "printing/image.h" 5 #include "printing/image.h"
6 6
7 #include <ApplicationServices/ApplicationServices.h> 7 #include <ApplicationServices/ApplicationServices.h>
8 #include <CoreFoundation/CoreFoundation.h> 8 #include <CoreFoundation/CoreFoundation.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <stdint.h> 10 #include <stdint.h>
11 11
12 #include "base/mac/scoped_cftyperef.h" 12 #include "base/mac/scoped_cftyperef.h"
13 #include "printing/metafile.h"
14 #include "printing/pdf_metafile_cg_mac.h" 13 #include "printing/pdf_metafile_cg_mac.h"
15 #include "ui/gfx/geometry/rect.h" 14 #include "ui/gfx/geometry/rect.h"
16 15
17 namespace printing { 16 namespace printing {
18 17
19 bool Image::LoadMetafile(const Metafile& metafile) { 18 bool Image::LoadMetafile(const void* metafile_src_buffer,
19 size_t metafile_src_buffer_size) {
20 PdfMetafileCg metafile;
21 if (!metafile.InitFromData(metafile_src_buffer, metafile_src_buffer_size)) {
22 return false;
23 }
20 // The printing system uses single-page metafiles (page indexes are 1-based). 24 // The printing system uses single-page metafiles (page indexes are 1-based).
21 const unsigned int page_number = 1; 25 const unsigned int page_number = 1;
22 gfx::Rect rect(metafile.GetPageBounds(page_number)); 26 gfx::Rect rect(metafile.GetPageBounds(page_number));
23 if (rect.width() < 1 || rect.height() < 1) 27 if (rect.width() < 1 || rect.height() < 1)
24 return false; 28 return false;
25 29
26 size_ = rect.size(); 30 size_ = rect.size();
27 row_length_ = size_.width() * sizeof(uint32_t); 31 row_length_ = size_.width() * sizeof(uint32_t);
28 size_t bytes = row_length_ * size_.height(); 32 size_t bytes = row_length_ * size_.height();
29 DCHECK(bytes); 33 DCHECK(bytes);
(...skipping 14 matching lines...) Expand all
44 PdfMetafileCg::RenderPageParams params; 48 PdfMetafileCg::RenderPageParams params;
45 params.shrink_to_fit = true; 49 params.shrink_to_fit = true;
46 CGRect cg_rect = CGRectMake(0, 0, size_.width(), size_.height()); 50 CGRect cg_rect = CGRectMake(0, 0, size_.width(), size_.height());
47 std::vector<char> buffer; 51 std::vector<char> buffer;
48 return metafile.GetDataAsVector(&buffer) && 52 return metafile.GetDataAsVector(&buffer) &&
49 PdfMetafileCg::RenderPage(buffer, page_number, bitmap_context, cg_rect, 53 PdfMetafileCg::RenderPage(buffer, page_number, bitmap_context, cg_rect,
50 params); 54 params);
51 } 55 }
52 56
53 } // namespace printing 57 } // namespace printing
OLDNEW
« printing/image.h ('K') | « printing/image_linux.cc ('k') | printing/image_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698