diff options
author | vandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-18 05:45:51 +0000 |
---|---|---|
committer | vandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-18 05:45:51 +0000 |
commit | f2da4b06dd189750cf2cd1db687b1106dce38ee8 (patch) | |
tree | 331027ffd36e5ffd618892e75b78abfedb627028 | |
parent | c8477a432601854d4e8e85a85cbbbf79af723ad2 (diff) | |
download | chromium_src-f2da4b06dd189750cf2cd1db687b1106dce38ee8.zip chromium_src-f2da4b06dd189750cf2cd1db687b1106dce38ee8.tar.gz chromium_src-f2da4b06dd189750cf2cd1db687b1106dce38ee8.tar.bz2 |
Revert 78666 - Cleanup NativeMetafile (win) interface and EMF class.
- Rename CreateDc to Init() and remove unused argument (all non-test calls were CreateDc(NULL, NULL). [This matches cross platform interface.]
- Remove CreateFileBackedDc from the NativeMetafile interface and make InitToFile() in the EMF class.
- Remove CreateFromFile from the NativeMetafile interface and make it InitFromFile() in the EMF class.
- Move the CloseEmf method into the destructor, making the Emf class a use once class (matches actual use).
BUG=NONE
TEST=NONE
Review URL: http://codereview.chromium.org/6695013
TBR=vandebo@chromium.org
Review URL: http://codereview.chromium.org/6712030
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78669 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/common/common_param_traits_unittest.cc | 4 | ||||
-rw-r--r-- | chrome/renderer/print_web_view_helper_win.cc | 8 | ||||
-rw-r--r-- | chrome/service/cloud_print/print_system_win.cc | 6 | ||||
-rw-r--r-- | chrome/service/service_utility_process_host.cc | 15 | ||||
-rw-r--r-- | chrome/service/service_utility_process_host.h | 6 | ||||
-rw-r--r-- | chrome/utility/utility_thread.cc | 20 | ||||
-rw-r--r-- | content/plugin/webplugin_delegate_stub.cc | 2 | ||||
-rw-r--r-- | printing/emf_win.cc | 42 | ||||
-rw-r--r-- | printing/emf_win.h | 29 | ||||
-rw-r--r-- | printing/emf_win_unittest.cc | 101 | ||||
-rw-r--r-- | printing/native_metafile.h | 23 |
11 files changed, 150 insertions, 106 deletions
diff --git a/chrome/common/common_param_traits_unittest.cc b/chrome/common/common_param_traits_unittest.cc index f9aabe1..7928032 100644 --- a/chrome/common/common_param_traits_unittest.cc +++ b/chrome/common/common_param_traits_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -241,7 +241,7 @@ TEST(IPCMessageTest, Metafile) { printing::NativeMetafileFactory::CreateMetafile()); RECT test_rect = {0, 0, 100, 100}; // Create a metafile using the screen DC as a reference. - metafile->Init(); + metafile->CreateDc(NULL, NULL); metafile->Close(); IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); diff --git a/chrome/renderer/print_web_view_helper_win.cc b/chrome/renderer/print_web_view_helper_win.cc index f248da94..72e3399 100644 --- a/chrome/renderer/print_web_view_helper_win.cc +++ b/chrome/renderer/print_web_view_helper_win.cc @@ -71,7 +71,7 @@ void PrintWebViewHelper::PrintPage(const ViewMsg_PrintPage_Params& params, // Each metafile contains a single page. scoped_ptr<printing::NativeMetafile> metafile( printing::NativeMetafileFactory::CreateMetafile()); - metafile->Init(); + metafile->CreateDc(NULL, NULL); DCHECK(metafile->context()); skia::PlatformDevice::InitializeDC(metafile->context()); @@ -108,6 +108,7 @@ void PrintWebViewHelper::PrintPage(const ViewMsg_PrintPage_Params& params, &(page_params.metafile_data_handle))) { page_params.data_size = 0; } + metafile->CloseEmf(); if (!Send(new ViewHostMsg_DuplicateSection( routing_id(), page_params.metafile_data_handle, @@ -138,7 +139,7 @@ void PrintWebViewHelper::CreatePreviewDocument( // http://code.google.com/p/chromium/issues/detail?id=62889 scoped_ptr<printing::NativeMetafile> metafile( printing::NativeMetafileFactory::CreateMetafile()); - metafile->Init(); + metafile->CreateDc(NULL, NULL); DCHECK(metafile->context()); skia::PlatformDevice::InitializeDC(metafile->context()); @@ -180,6 +181,7 @@ void PrintWebViewHelper::CreatePreviewDocument( preview_params.data_size = 0; preview_params.expected_pages_count = 0; } + metafile->CloseEmf(); if (!Send(new ViewHostMsg_DuplicateSection( routing_id(), preview_params.metafile_data_handle, @@ -287,7 +289,7 @@ void PrintWebViewHelper::RenderPage( HBRUSH whiteBrush = static_cast<HBRUSH>(GetStockObject(WHITE_BRUSH)); FillRect(bitmap_dc, &rect, whiteBrush); - metafile2->Init(); + metafile2->CreateDc(NULL, NULL); HDC hdc = metafile2->context(); DCHECK(hdc); skia::PlatformDevice::InitializeDC(hdc); diff --git a/chrome/service/cloud_print/print_system_win.cc b/chrome/service/cloud_print/print_system_win.cc index e963403..01caaa8 100644 --- a/chrome/service/cloud_print/print_system_win.cc +++ b/chrome/service/cloud_print/print_system_win.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -26,7 +26,7 @@ #include "printing/backend/print_backend.h" #include "printing/backend/print_backend_consts.h" #include "printing/backend/win_helper.h" -#include "printing/emf_win.h" +#include "printing/native_metafile.h" #include "printing/page_range.h" #include "ui/base/l10n/l10n_util.h" #include "ui/gfx/rect.h" @@ -448,7 +448,7 @@ class PrintSystemWin : public PrintSystem { // ServiceUtilityProcessHost::Client implementation. virtual void OnRenderPDFPagesToMetafileSucceeded( - const printing::Emf& metafile, + const printing::NativeMetafile& metafile, int highest_rendered_page_number) { metafile.SafePlayback(printer_dc_.Get()); bool done_printing = (highest_rendered_page_number != diff --git a/chrome/service/service_utility_process_host.cc b/chrome/service/service_utility_process_host.cc index fb5080c..a340d8d 100644 --- a/chrome/service/service_utility_process_host.cc +++ b/chrome/service/service_utility_process_host.cc @@ -20,7 +20,8 @@ #if defined(OS_WIN) #include "base/scoped_ptr.h" #include "base/win/scoped_handle.h" -#include "printing/emf_win.h" +#include "printing/native_metafile_factory.h" +#include "printing/native_metafile.h" #endif ServiceUtilityProcessHost::ServiceUtilityProcessHost( @@ -203,15 +204,15 @@ void ServiceUtilityProcessHost::Client::MetafileAvailable( if (!scratch_metafile_dir.Set(metafile_path.DirName())) LOG(WARNING) << "Unable to set scratch metafile directory"; #if defined(OS_WIN) - // It's important that metafile is declared after scratch_metafile_dir so - // that the metafile destructor closes the file before the ScopedTempDir - // destructor tries to remove the directory. - printing::Emf metafile; - if (!metafile.InitFromFile(metafile_path)) { + scoped_ptr<printing::NativeMetafile> metafile( + printing::NativeMetafileFactory::CreateMetafile()); + if (!metafile->CreateFromFile(metafile_path)) { OnRenderPDFPagesToMetafileFailed(); } else { - OnRenderPDFPagesToMetafileSucceeded(metafile, + OnRenderPDFPagesToMetafileSucceeded(*metafile, highest_rendered_page_number); + // Close it so that ScopedTempDir can delete the folder. + metafile->CloseEmf(); } #endif // defined(OS_WIN) } diff --git a/chrome/service/service_utility_process_host.h b/chrome/service/service_utility_process_host.h index ad7eb3e..b770e1a 100644 --- a/chrome/service/service_utility_process_host.h +++ b/chrome/service/service_utility_process_host.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -21,6 +21,7 @@ #include "base/task.h" #include "ipc/ipc_channel.h" #include "chrome/service/service_child_process_host.h" +#include "printing/native_metafile.h" class CommandLine; class ScopedTempDir; @@ -34,7 +35,6 @@ class Rect; } // namespace gfx namespace printing { -class Emf; struct PageRange; struct PrinterCapsAndDefaults; } // namespace printing @@ -57,7 +57,7 @@ class ServiceUtilityProcessHost : public ServiceChildProcessHost { // Called when at least one page in the specified PDF has been rendered // successfully into |metafile|. virtual void OnRenderPDFPagesToMetafileSucceeded( - const printing::Emf& metafile, + const printing::NativeMetafile& metafile, int highest_rendered_page_number) {} // Called when no page in the passed in PDF could be rendered. virtual void OnRenderPDFPagesToMetafileFailed() {} diff --git a/chrome/utility/utility_thread.cc b/chrome/utility/utility_thread.cc index 9fc175c6..7b665ae 100644 --- a/chrome/utility/utility_thread.cc +++ b/chrome/utility/utility_thread.cc @@ -30,7 +30,8 @@ #include "app/win/iat_patch_function.h" #include "base/scoped_ptr.h" #include "base/win/scoped_handle.h" -#include "printing/emf_win.h" +#include "printing/native_metafile_factory.h" +#include "printing/native_metafile.h" #endif namespace { @@ -256,17 +257,18 @@ bool UtilityThread::RenderPDFToWinMetafile( if (!get_info_proc(&buffer.front(), buffer.size(), &total_page_count, NULL)) return false; - printing::Emf metafile; - metafile.InitToFile(metafile_path); + scoped_ptr<printing::NativeMetafile> metafile( + printing::NativeMetafileFactory::CreateMetafile()); + metafile->CreateFileBackedDc(NULL, NULL, metafile_path); // Since we created the metafile using the screen DPI (but we actually want // the PDF DLL to print using the passed in render_dpi, we apply the following // transformation. - SetGraphicsMode(metafile.context(), GM_ADVANCED); + SetGraphicsMode(metafile->context(), GM_ADVANCED); XFORM xform = {0}; int screen_dpi = GetDeviceCaps(GetDC(NULL), LOGPIXELSX); xform.eM11 = xform.eM22 = static_cast<float>(screen_dpi) / static_cast<float>(render_dpi); - ModifyWorldTransform(metafile.context(), &xform, MWT_LEFTMULTIPLY); + ModifyWorldTransform(metafile->context(), &xform, MWT_LEFTMULTIPLY); bool ret = false; std::vector<printing::PageRange>::const_iterator iter; @@ -274,18 +276,18 @@ bool UtilityThread::RenderPDFToWinMetafile( for (int page_number = iter->from; page_number <= iter->to; ++page_number) { if (page_number >= total_page_count) break; - metafile.StartPage(); + metafile->StartPage(); if (render_proc(&buffer.front(), buffer.size(), page_number, - metafile.context(), render_dpi, render_dpi, + metafile->context(), render_dpi, render_dpi, render_area.x(), render_area.y(), render_area.width(), render_area.height(), true, false, true, true)) if (*highest_rendered_page_number < page_number) *highest_rendered_page_number = page_number; ret = true; - metafile.FinishPage(); + metafile->FinishPage(); } } - metafile.Close(); + metafile->Close(); return ret; } #endif // defined(OS_WIN) diff --git a/content/plugin/webplugin_delegate_stub.cc b/content/plugin/webplugin_delegate_stub.cc index a0fa40a..cf26fc0 100644 --- a/content/plugin/webplugin_delegate_stub.cc +++ b/content/plugin/webplugin_delegate_stub.cc @@ -273,7 +273,7 @@ void WebPluginDelegateStub::OnPrint(base::SharedMemoryHandle* shared_memory, #if defined(OS_WIN) scoped_ptr<printing::NativeMetafile> metafile( printing::NativeMetafileFactory::CreateMetafile()); - if (!metafile->Init()) { + if (!metafile->CreateDc(NULL, NULL)) { NOTREACHED(); return; } diff --git a/printing/emf_win.cc b/printing/emf_win.cc index 7e3dbeb..6fea291 100644 --- a/printing/emf_win.cc +++ b/printing/emf_win.cc @@ -50,39 +50,41 @@ Emf::Emf() : emf_(NULL), hdc_(NULL) { } Emf::~Emf() { - DCHECK(!hdc_); - if (emf_) - DeleteEnhMetaFile(emf_); + CloseEmf(); + DCHECK(!emf_ && !hdc_); } -bool Emf::InitToFile(const FilePath& metafile_path) { +bool Emf::InitFromData(const void* src_buffer, uint32 src_buffer_size) { DCHECK(!emf_ && !hdc_); - hdc_ = CreateEnhMetaFile(NULL, metafile_path.value().c_str(), NULL, NULL); - DCHECK(hdc_); - return hdc_ != NULL; + emf_ = SetEnhMetaFileBits(src_buffer_size, + reinterpret_cast<const BYTE*>(src_buffer)); + return emf_ != NULL; } -bool Emf::InitFromFile(const FilePath& metafile_path) { +bool Emf::CreateDc(HDC sibling, const RECT* rect) { DCHECK(!emf_ && !hdc_); - emf_ = GetEnhMetaFile(metafile_path.value().c_str()); - DCHECK(emf_); - return emf_ != NULL; + hdc_ = CreateEnhMetaFile(sibling, NULL, rect, NULL); + DCHECK(hdc_); + return hdc_ != NULL; } -bool Emf::Init() { +bool Emf::CreateFileBackedDc(HDC sibling, const RECT* rect, + const FilePath& path) { DCHECK(!emf_ && !hdc_); - hdc_ = CreateEnhMetaFile(NULL, NULL, NULL, NULL); + DCHECK(!path.empty()); + hdc_ = CreateEnhMetaFile(sibling, path.value().c_str(), rect, NULL); DCHECK(hdc_); return hdc_ != NULL; } -bool Emf::InitFromData(const void* src_buffer, uint32 src_buffer_size) { +bool Emf::CreateFromFile(const FilePath& metafile_path) { DCHECK(!emf_ && !hdc_); - emf_ = SetEnhMetaFileBits(src_buffer_size, - reinterpret_cast<const BYTE*>(src_buffer)); + emf_ = GetEnhMetaFile(metafile_path.value().c_str()); + DCHECK(emf_); return emf_ != NULL; } + bool Emf::Close() { DCHECK(!emf_ && hdc_); emf_ = CloseEnhMetaFile(hdc_); @@ -91,6 +93,14 @@ bool Emf::Close() { return emf_ != NULL; } +void Emf::CloseEmf() { + DCHECK(!hdc_); + if (emf_) { + DeleteEnhMetaFile(emf_); + emf_ = NULL; + } +} + bool Emf::Playback(HDC hdc, const RECT* rect) const { DCHECK(emf_ && !hdc_); RECT bounds; diff --git a/printing/emf_win.h b/printing/emf_win.h index 0503e6f..5150356 100644 --- a/printing/emf_win.h +++ b/printing/emf_win.h @@ -27,20 +27,10 @@ class Emf : public NativeMetafile { class Enumerator; struct EnumerationContext; - // Generates a virtual HDC that will record every GDI commands and compile - // it in a EMF data stream. - Emf(); virtual ~Emf(); - // Generates a new metafile that will record every GDI command, and will - // be saved to |metafile_path|. - virtual bool InitToFile(const FilePath& metafile_path); - - // Initializes the Emf with the data in |metafile_path|. - virtual bool InitFromFile(const FilePath& metafile_path); - // NativeMetafile methods. - virtual bool Init(); + virtual bool Init() { return true; } virtual bool InitFromData(const void* src_buffer, uint32 src_buffer_size); virtual bool StartPage(); @@ -67,6 +57,14 @@ class Emf : public NativeMetafile { return hdc_; } + virtual bool CreateDc(HDC sibling, const RECT* rect); + virtual bool CreateFileBackedDc(HDC sibling, + const RECT* rect, + const FilePath& path); + virtual bool CreateFromFile(const FilePath& file_path); + + virtual void CloseEmf(); + virtual bool Playback(HDC hdc, const RECT* rect) const; virtual bool SafePlayback(HDC hdc) const; @@ -76,7 +74,16 @@ class Emf : public NativeMetafile { return emf_; } + protected: + Emf(); + private: + friend class NativeMetafileFactory; + FRIEND_TEST_ALL_PREFIXES(EmfTest, DC); + FRIEND_TEST_ALL_PREFIXES(EmfTest, FileBackedDC); + FRIEND_TEST_ALL_PREFIXES(EmfPrintingTest, Enumerate); + FRIEND_TEST_ALL_PREFIXES(EmfPrintingTest, PageBreak); + // Playbacks safely one EMF record. static int CALLBACK SafePlaybackProc(HDC hdc, HANDLETABLE* handle_table, diff --git a/printing/emf_win_unittest.cc b/printing/emf_win_unittest.cc index 16ca82e..2f4e2ae 100644 --- a/printing/emf_win_unittest.cc +++ b/printing/emf_win_unittest.cc @@ -43,26 +43,26 @@ namespace printing { TEST(EmfTest, DC) { // Simplest use case. - uint32 size; + printing::Emf emf; + RECT rect = {100, 100, 200, 200}; + HDC hdc = CreateCompatibleDC(NULL); + EXPECT_TRUE(hdc != NULL); + EXPECT_TRUE(emf.CreateDc(hdc, &rect)); + EXPECT_TRUE(emf.context() != NULL); + // In theory, you'd use the HDC with GDI functions here. + EXPECT_TRUE(emf.Close()); + uint32 size = emf.GetDataSize(); + EXPECT_EQ(size, EMF_HEADER_SIZE); std::vector<BYTE> data; - { - printing::Emf emf; - EXPECT_TRUE(emf.Init()); - EXPECT_TRUE(emf.context() != NULL); - // An empty EMF is invalid, so we put at least a rectangle in it. - ::Rectangle(emf.context(), 10, 10, 190, 190); - EXPECT_TRUE(emf.Close()); - size = emf.GetDataSize(); - EXPECT_GT(size, EMF_HEADER_SIZE); - EXPECT_TRUE(emf.GetData(&data)); - EXPECT_EQ(data.size(), size); - } + EXPECT_TRUE(emf.GetData(&data)); + EXPECT_EQ(data.size(), size); + emf.CloseEmf(); + EXPECT_TRUE(DeleteDC(hdc)); // Playback the data. - printing::Emf emf; - EXPECT_TRUE(emf.InitFromData(&data.front(), size)); - HDC hdc = CreateCompatibleDC(NULL); + hdc = CreateCompatibleDC(NULL); EXPECT_TRUE(hdc); + EXPECT_TRUE(emf.InitFromData(&data.front(), size)); RECT output_rect = {0, 0, 10, 10}; EXPECT_TRUE(emf.Playback(hdc, &output_rect)); EXPECT_TRUE(DeleteDC(hdc)); @@ -126,31 +126,28 @@ TEST_F(EmfPrintingTest, PageBreak) { CreateDC(L"WINSPOOL", L"UnitTest Printer", NULL, NULL)); if (!dc.Get()) return; - uint32 size; - std::vector<BYTE> data; - { - printing::Emf emf; - EXPECT_TRUE(emf.Init()); - EXPECT_TRUE(emf.context() != NULL); - int pages = 3; - while (pages) { - EXPECT_TRUE(emf.StartPage()); - ::Rectangle(emf.context(), 10, 10, 190, 190); - EXPECT_TRUE(emf.FinishPage()); - --pages; - } - EXPECT_TRUE(emf.Close()); - size = emf.GetDataSize(); - EXPECT_TRUE(emf.GetData(&data)); - EXPECT_EQ(data.size(), size); + printing::Emf emf; + EXPECT_TRUE(emf.CreateDc(dc.Get(), NULL)); + EXPECT_TRUE(emf.context() != NULL); + int pages = 3; + while (pages) { + EXPECT_TRUE(emf.StartPage()); + ::Rectangle(emf.context(), 10, 10, 190, 190); + EXPECT_TRUE(emf.FinishPage()); + --pages; } + EXPECT_TRUE(emf.Close()); + uint32 size = emf.GetDataSize(); + std::vector<BYTE> data; + EXPECT_TRUE(emf.GetData(&data)); + EXPECT_EQ(data.size(), size); + emf.CloseEmf(); // Playback the data. DOCINFO di = {0}; di.cbSize = sizeof(DOCINFO); di.lpszDocName = L"Test Job"; int job_id = ::StartDoc(dc.Get(), &di); - printing::Emf emf; EXPECT_TRUE(emf.InitFromData(&data.front(), size)); EXPECT_TRUE(emf.SafePlayback(dc.Get())); ::EndDoc(dc.Get()); @@ -163,39 +160,41 @@ TEST_F(EmfPrintingTest, PageBreak) { } } -TEST(EmfTest, FileBackedEmf) { +TEST(EmfTest, FileBackedDC) { // Simplest use case. + printing::Emf emf; + RECT rect = {100, 100, 200, 200}; + HDC hdc = CreateCompatibleDC(NULL); + EXPECT_TRUE(hdc != NULL); ScopedTempDir scratch_metafile_dir; ASSERT_TRUE(scratch_metafile_dir.CreateUniqueTempDir()); FilePath metafile_path; EXPECT_TRUE(file_util::CreateTemporaryFileInDir(scratch_metafile_dir.path(), &metafile_path)); - uint32 size; + EXPECT_TRUE(emf.CreateFileBackedDc(hdc, &rect, metafile_path)); + EXPECT_TRUE(emf.context() != NULL); + // In theory, you'd use the HDC with GDI functions here. + EXPECT_TRUE(emf.Close()); + + uint32 size = emf.GetDataSize(); + EXPECT_EQ(size, EMF_HEADER_SIZE); std::vector<BYTE> data; - { - printing::Emf emf; - EXPECT_TRUE(emf.InitToFile(metafile_path)); - EXPECT_TRUE(emf.context() != NULL); - // An empty EMF is invalid, so we put at least a rectangle in it. - ::Rectangle(emf.context(), 10, 10, 190, 190); - EXPECT_TRUE(emf.Close()); - size = emf.GetDataSize(); - EXPECT_GT(size, EMF_HEADER_SIZE); - EXPECT_TRUE(emf.GetData(&data)); - EXPECT_EQ(data.size(), size); - } + EXPECT_TRUE(emf.GetData(&data)); + EXPECT_EQ(data.size(), size); + emf.CloseEmf(); int64 file_size = 0; file_util::GetFileSize(metafile_path, &file_size); EXPECT_EQ(size, file_size); + EXPECT_TRUE(DeleteDC(hdc)); // Playback the data. - HDC hdc = CreateCompatibleDC(NULL); + hdc = CreateCompatibleDC(NULL); EXPECT_TRUE(hdc); - printing::Emf emf; - EXPECT_TRUE(emf.InitFromFile(metafile_path)); + EXPECT_TRUE(emf.CreateFromFile(metafile_path)); RECT output_rect = {0, 0, 10, 10}; EXPECT_TRUE(emf.Playback(hdc, &output_rect)); EXPECT_TRUE(DeleteDC(hdc)); + emf.CloseEmf(); } } // namespace printing diff --git a/printing/native_metafile.h b/printing/native_metafile.h index 08b3277..a076b32 100644 --- a/printing/native_metafile.h +++ b/printing/native_metafile.h @@ -101,6 +101,29 @@ class NativeMetafile { virtual gfx::NativeDrawingContext context() const = 0; #if defined(OS_WIN) + // Generates a virtual HDC that will record every GDI commands and compile it + // in a EMF data stream. + // hdc is used to setup the default DPI and color settings. hdc is optional. + // rect specifies the dimensions (in .01-millimeter units) of the EMF. rect is + // optional. + virtual bool CreateDc(gfx::NativeDrawingContext sibling, + const RECT* rect) = 0; + + // Similar to the above method but the metafile is backed by a file. + virtual bool CreateFileBackedDc(gfx::NativeDrawingContext sibling, + const RECT* rect, + const FilePath& path) = 0; + + // TODO(maruel): CreateFromFile(). If ever used. Maybe users would like to + // have the ability to save web pages to an EMF file? Afterward, it is easy to + // convert to PDF or PS. + // Load a metafile fromdisk. + virtual bool CreateFromFile(const FilePath& metafile_path) = 0; + + // Closes the HDC created by CreateDc() and generates the compiled EMF + // data. + virtual void CloseEmf() = 0; + // "Plays" the EMF buffer in a HDC. It is the same effect as calling the // original GDI function that were called when recording the EMF. |rect| is in // "logical units" and is optional. If |rect| is NULL, the natural EMF bounds |