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

Unified Diff: printing/emf_win.cc

Issue 568633002: Extracted MetafilePlayer interface from printing::MetafilePlayer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@no_expose
Patch Set: Thu Sep 11 22:54:16 PDT 2014 Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « printing/emf_win.h ('k') | printing/emf_win_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: printing/emf_win.cc
diff --git a/printing/emf_win.cc b/printing/emf_win.cc
index b6c9b4fc6d1c39e4b9a0f321de7e06d710e28b60..5497495af5d35f238f82482fd43dc603a1f05b6d 100644
--- a/printing/emf_win.cc
+++ b/printing/emf_win.cc
@@ -4,6 +4,7 @@
#include "printing/emf_win.h"
+#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
@@ -273,38 +274,6 @@ bool Emf::GetData(void* buffer, uint32 size) const {
return size2 == size && size2 != 0;
}
-bool Emf::GetDataAsVector(std::vector<uint8>* buffer) const {
- uint32 size = GetDataSize();
- if (!size)
- return false;
-
- buffer->resize(size);
- if (!GetData(&buffer->front(), size))
- return false;
- return true;
-}
-
-bool Emf::SaveTo(const base::FilePath& file_path) const {
- HANDLE file = CreateFile(file_path.value().c_str(), GENERIC_WRITE,
- FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
- CREATE_ALWAYS, 0, NULL);
- if (file == INVALID_HANDLE_VALUE)
- return false;
-
- bool success = false;
- std::vector<uint8> buffer;
- if (GetDataAsVector(&buffer)) {
- DWORD written = 0;
- if (WriteFile(file, &*buffer.begin(), static_cast<DWORD>(buffer.size()),
- &written, NULL) &&
- written == buffer.size()) {
- success = true;
- }
- }
- CloseHandle(file);
- return success;
-}
-
int CALLBACK Emf::SafePlaybackProc(HDC hdc,
HANDLETABLE* handle_table,
const ENHMETARECORD* record,
@@ -606,7 +575,7 @@ bool Emf::IsAlphaBlendUsed() const {
return result;
}
-Emf* Emf::RasterizeMetafile(int raster_area_in_pixels) const {
+scoped_ptr<Emf> Emf::RasterizeMetafile(int raster_area_in_pixels) const {
gfx::Rect page_bounds = GetPageBounds(1);
gfx::Size page_size(page_bounds.size());
if (page_size.GetArea() <= 0) {
@@ -648,10 +617,10 @@ Emf* Emf::RasterizeMetafile(int raster_area_in_pixels) const {
result->FinishPage();
result->FinishDocument();
- return result.release();
+ return result.Pass();
}
-Emf* Emf::RasterizeAlphaBlend() const {
+scoped_ptr<Emf> Emf::RasterizeAlphaBlend() const {
gfx::Rect page_bounds = GetPageBounds(1);
if (page_bounds.size().GetArea() <= 0) {
NOTREACHED() << "Metafile is empty";
@@ -676,7 +645,7 @@ Emf* Emf::RasterizeAlphaBlend() const {
result->FinishDocument();
- return result.release();
+ return result.Pass();
}
« no previous file with comments | « printing/emf_win.h ('k') | printing/emf_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698