diff options
author | vandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-04 23:15:06 +0000 |
---|---|---|
committer | vandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-04 23:15:06 +0000 |
commit | 9b61753963f16cc6cf48f388a2c24e064add4cbb (patch) | |
tree | 6fbae6593eb9465c320a5f35ebdaa24612818bb0 | |
parent | 22796b1a1791a0d1e84bf2d0eeba82d08d0687c1 (diff) | |
download | chromium_src-9b61753963f16cc6cf48f388a2c24e064add4cbb.zip chromium_src-9b61753963f16cc6cf48f388a2c24e064add4cbb.tar.gz chromium_src-9b61753963f16cc6cf48f388a2c24e064add4cbb.tar.bz2 |
Rename some printing classes and minor cleanups.
Rename:
PdfPsMetafile -> PdfMetafileCairo
PdfMetafile -> PdfMetafileCg (Mac)
VectorPlatformDevice -> VectorPlatformDeviceEmf/Cairo (Windows/Linux varients)
This is in preparation for VectorPlatformDeviceSkia.
BUG=NONE
TEST=NONE
Review URL: http://codereview.chromium.org/6783036
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80390 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/renderer/print_web_view_helper_win.cc | 6 | ||||
-rw-r--r-- | printing/emf_win.cc | 8 | ||||
-rw-r--r-- | printing/native_metafile_factory.cc | 8 | ||||
-rw-r--r-- | printing/pdf_metafile_cairo_linux.cc (renamed from printing/pdf_ps_metafile_cairo.cc) | 54 | ||||
-rw-r--r-- | printing/pdf_metafile_cairo_linux.h (renamed from printing/pdf_ps_metafile_cairo.h) | 16 | ||||
-rw-r--r-- | printing/pdf_metafile_cairo_linux_unittest.cc (renamed from printing/pdf_ps_metafile_cairo_unittest.cc) | 12 | ||||
-rw-r--r-- | printing/pdf_metafile_cg_mac.cc (renamed from printing/pdf_metafile_mac.cc) | 49 | ||||
-rw-r--r-- | printing/pdf_metafile_cg_mac.h (renamed from printing/pdf_metafile_mac.h) | 16 | ||||
-rw-r--r-- | printing/pdf_metafile_cg_mac_unittest.cc (renamed from printing/pdf_metafile_mac_unittest.cc) | 8 | ||||
-rw-r--r-- | printing/print_settings_initializer_gtk.cc | 1 | ||||
-rw-r--r-- | printing/printing.gyp | 12 | ||||
-rw-r--r-- | skia/ext/platform_device_linux.h | 4 | ||||
-rw-r--r-- | skia/ext/vector_canvas.cc | 4 | ||||
-rw-r--r-- | skia/ext/vector_canvas_unittest.cc | 8 | ||||
-rw-r--r-- | skia/ext/vector_platform_device.h | 23 | ||||
-rw-r--r-- | skia/ext/vector_platform_device_cairo_linux.cc (renamed from skia/ext/vector_platform_device_linux.cc) | 194 | ||||
-rw-r--r-- | skia/ext/vector_platform_device_cairo_linux.h (renamed from skia/ext/vector_platform_device_linux.h) | 29 | ||||
-rw-r--r-- | skia/ext/vector_platform_device_emf_win.cc (renamed from skia/ext/vector_platform_device_win.cc) | 192 | ||||
-rw-r--r-- | skia/ext/vector_platform_device_emf_win.h (renamed from skia/ext/vector_platform_device_win.h) | 25 | ||||
-rw-r--r-- | skia/skia.gyp | 9 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppapi_plugin_instance.cc | 10 |
21 files changed, 334 insertions, 354 deletions
diff --git a/chrome/renderer/print_web_view_helper_win.cc b/chrome/renderer/print_web_view_helper_win.cc index b7ed1cb..e7a6c97 100644 --- a/chrome/renderer/print_web_view_helper_win.cc +++ b/chrome/renderer/print_web_view_helper_win.cc @@ -11,7 +11,7 @@ #include "printing/native_metafile.h" #include "printing/units.h" #include "skia/ext/vector_canvas.h" -#include "skia/ext/vector_platform_device.h" +#include "skia/ext/vector_platform_device_emf_win.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" #include "ui/gfx/gdi_util.h" #include "ui/gfx/point.h" @@ -230,8 +230,8 @@ void PrintWebViewHelper::RenderPage( bool result = (*metafile)->FinishPage(); DCHECK(result); - skia::VectorPlatformDevice* platform_device = - static_cast<skia::VectorPlatformDevice*>(device); + skia::VectorPlatformDeviceEmf* platform_device = + static_cast<skia::VectorPlatformDeviceEmf*>(device); if (platform_device->alpha_blend_used() && !params.supports_alpha_blend) { // Currently, we handle alpha blend transparency for a single page. // Therefore, expecting a metafile with page count 1. diff --git a/printing/emf_win.cc b/printing/emf_win.cc index 849e125..1b5601a 100644 --- a/printing/emf_win.cc +++ b/printing/emf_win.cc @@ -9,7 +9,7 @@ #include "base/memory/scoped_ptr.h" #include "base/metrics/histogram.h" #include "base/time.h" -#include "skia/ext/vector_platform_device_win.h" +#include "skia/ext/vector_platform_device_emf_win.h" #include "third_party/skia/include/core/SkBitmap.h" #include "ui/gfx/codec/jpeg_codec.h" #include "ui/gfx/codec/png_codec.h" @@ -409,9 +409,9 @@ skia::PlatformDevice* Emf::StartPageForVectorCanvas( if (!StartPage(page_size, content_origin, scale_factor)) return NULL; - return skia::VectorPlatformDeviceFactory::CreateDevice(page_size.width(), - page_size.height(), - true, hdc_); + return skia::VectorPlatformDeviceEmfFactory::CreateDevice(page_size.width(), + page_size.height(), + true, hdc_); } bool Emf::StartPage(const gfx::Size& /*page_size*/, diff --git a/printing/native_metafile_factory.cc b/printing/native_metafile_factory.cc index 3b77ae0..5db823e 100644 --- a/printing/native_metafile_factory.cc +++ b/printing/native_metafile_factory.cc @@ -9,9 +9,9 @@ #if defined(OS_WIN) #include "printing/emf_win.h" #elif defined(OS_MACOSX) -#include "printing/pdf_metafile_mac.h" +#include "printing/pdf_metafile_cg_mac.h" #elif defined(OS_POSIX) -#include "printing/pdf_ps_metafile_cairo.h" +#include "printing/pdf_metafile_cairo_linux.h" #endif namespace printing { @@ -38,9 +38,9 @@ NativeMetafile* NativeMetafileFactory::CreateNewMetafile(){ #if defined(OS_WIN) return new printing::Emf; #elif defined(OS_MACOSX) - return new printing::PdfMetafile; + return new printing::PdfMetafileCg; #elif defined(OS_POSIX) - return new printing::PdfPsMetafile; + return new printing::PdfMetafileCairo; #endif } diff --git a/printing/pdf_ps_metafile_cairo.cc b/printing/pdf_metafile_cairo_linux.cc index a10b125..5780574 100644 --- a/printing/pdf_ps_metafile_cairo.cc +++ b/printing/pdf_metafile_cairo_linux.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "printing/pdf_ps_metafile_cairo.h" +#include "printing/pdf_metafile_cairo_linux.h" #include <stdio.h> @@ -14,7 +14,7 @@ #include "base/file_util.h" #include "base/logging.h" #include "printing/units.h" -#include "skia/ext/vector_platform_device_linux.h" +#include "skia/ext/vector_platform_device_cairo_linux.h" #include "ui/gfx/rect.h" #include "ui/gfx/size.h" @@ -65,18 +65,18 @@ cairo_status_t WriteCairoStream(void* dst_buffer, namespace printing { -PdfPsMetafile::PdfPsMetafile() +PdfMetafileCairo::PdfMetafileCairo() : surface_(NULL), context_(NULL), current_data_(NULL) { } -PdfPsMetafile::~PdfPsMetafile() { +PdfMetafileCairo::~PdfMetafileCairo() { // Releases all resources if we forgot to do so. CleanUpAll(); } -bool PdfPsMetafile::Init() { +bool PdfMetafileCairo::Init() { // We need to check |current_data_| to ensure Init/InitFromData has not been // called before. DCHECK(!current_data_); @@ -90,7 +90,7 @@ bool PdfPsMetafile::Init() { // Cairo always returns a valid pointer. // Hence, we have to check if it points to a "nil" object. if (!IsSurfaceValid(surface_)) { - DLOG(ERROR) << "Cannot create Cairo surface for PdfPsMetafile!"; + DLOG(ERROR) << "Cannot create Cairo surface for PdfMetafileCairo!"; CleanUpSurface(&surface_); return false; } @@ -98,7 +98,7 @@ bool PdfPsMetafile::Init() { // Creates a context. context_ = cairo_create(surface_); if (!IsContextValid(context_)) { - DLOG(ERROR) << "Cannot create Cairo context for PdfPsMetafile!"; + DLOG(ERROR) << "Cannot create Cairo context for PdfMetafileCairo!"; CleanUpContext(&context_); CleanUpSurface(&surface_); return false; @@ -107,8 +107,8 @@ bool PdfPsMetafile::Init() { return true; } -bool PdfPsMetafile::InitFromData(const void* src_buffer, - uint32 src_buffer_size) { +bool PdfMetafileCairo::InitFromData(const void* src_buffer, + uint32 src_buffer_size) { if (src_buffer == NULL || src_buffer_size == 0) return false; @@ -118,21 +118,19 @@ bool PdfPsMetafile::InitFromData(const void* src_buffer, return true; } -skia::PlatformDevice* PdfPsMetafile::StartPageForVectorCanvas( +skia::PlatformDevice* PdfMetafileCairo::StartPageForVectorCanvas( const gfx::Size& page_size, const gfx::Point& content_origin, const float& scale_factor) { if (!StartPage(page_size, content_origin, scale_factor)) return NULL; - return skia::VectorPlatformDeviceFactory::CreateDevice(context_, - page_size.width(), - page_size.height(), - true); + return skia::VectorPlatformDeviceCairoFactory::CreateDevice( + context_, page_size.width(), page_size.height(), true); } -bool PdfPsMetafile::StartPage(const gfx::Size& page_size, - const gfx::Point& content_origin, - const float& scale_factor) { +bool PdfMetafileCairo::StartPage(const gfx::Size& page_size, + const gfx::Point& content_origin, + const float& scale_factor) { DCHECK(IsSurfaceValid(surface_)); DCHECK(IsContextValid(context_)); // Passing this check implies page_surface_ is NULL, and current_page_ is @@ -151,7 +149,7 @@ bool PdfPsMetafile::StartPage(const gfx::Size& page_size, return context_ != NULL; } -bool PdfPsMetafile::FinishPage() { +bool PdfMetafileCairo::FinishPage() { DCHECK(IsSurfaceValid(surface_)); DCHECK(IsContextValid(context_)); @@ -161,7 +159,7 @@ bool PdfPsMetafile::FinishPage() { return true; } -bool PdfPsMetafile::FinishDocument() { +bool PdfMetafileCairo::FinishDocument() { DCHECK(IsSurfaceValid(surface_)); DCHECK(IsContextValid(context_)); @@ -174,7 +172,7 @@ bool PdfPsMetafile::FinishDocument() { return true; } -uint32 PdfPsMetafile::GetDataSize() const { +uint32 PdfMetafileCairo::GetDataSize() const { // We need to check at least these two members to ensure that either Init() // has been called to initialize |data_|, or metafile has been closed. DCHECK(!context_); @@ -183,7 +181,7 @@ uint32 PdfPsMetafile::GetDataSize() const { return current_data_->size(); } -bool PdfPsMetafile::GetData(void* dst_buffer, uint32 dst_buffer_size) const { +bool PdfMetafileCairo::GetData(void* dst_buffer, uint32 dst_buffer_size) const { DCHECK(dst_buffer); DCHECK_GT(dst_buffer_size, 0u); memcpy(dst_buffer, current_data_->data(), dst_buffer_size); @@ -191,11 +189,11 @@ bool PdfPsMetafile::GetData(void* dst_buffer, uint32 dst_buffer_size) const { return true; } -cairo_t* PdfPsMetafile::context() const { +cairo_t* PdfMetafileCairo::context() const { return context_; } -bool PdfPsMetafile::SaveTo(const FilePath& file_path) const { +bool PdfMetafileCairo::SaveTo(const FilePath& file_path) const { // We need to check at least these two members to ensure that either Init() // has been called to initialize |data_|, or metafile has been closed. DCHECK(!context_); @@ -210,18 +208,18 @@ bool PdfPsMetafile::SaveTo(const FilePath& file_path) const { return success; } -gfx::Rect PdfPsMetafile::GetPageBounds(unsigned int page_number) const { +gfx::Rect PdfMetafileCairo::GetPageBounds(unsigned int page_number) const { NOTIMPLEMENTED(); return gfx::Rect(); } -unsigned int PdfPsMetafile::GetPageCount() const { +unsigned int PdfMetafileCairo::GetPageCount() const { NOTIMPLEMENTED(); return 1; } #if defined(OS_CHROMEOS) -bool PdfPsMetafile::SaveToFD(const base::FileDescriptor& fd) const { +bool PdfMetafileCairo::SaveToFD(const base::FileDescriptor& fd) const { // We need to check at least these two members to ensure that either Init() // has been called to initialize |data_|, or metafile has been closed. DCHECK(!context_); @@ -250,12 +248,12 @@ bool PdfPsMetafile::SaveToFD(const base::FileDescriptor& fd) const { } #endif // if defined(OS_CHROMEOS) -void PdfPsMetafile::CleanUpAll() { +void PdfMetafileCairo::CleanUpAll() { CleanUpContext(&context_); CleanUpSurface(&surface_); cairo_data_.clear(); raw_data_.clear(); - skia::VectorPlatformDevice::ClearFontCache(); + skia::VectorPlatformDeviceCairo::ClearFontCache(); } } // namespace printing diff --git a/printing/pdf_ps_metafile_cairo.h b/printing/pdf_metafile_cairo_linux.h index 6d5cf5c..f3a80aa 100644 --- a/printing/pdf_ps_metafile_cairo.h +++ b/printing/pdf_metafile_cairo_linux.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef PRINTING_PDF_PS_METAFILE_CAIRO_H_ -#define PRINTING_PDF_PS_METAFILE_CAIRO_H_ +#ifndef PRINTING_PDF_METAFILE_CAIRO_LINUX_H_ +#define PRINTING_PDF_METAFILE_CAIRO_LINUX_H_ #include <string> @@ -23,9 +23,9 @@ namespace printing { // This class uses Cairo graphics library to generate PDF stream and stores // rendering results in a string buffer. -class PdfPsMetafile : public NativeMetafile { +class PdfMetafileCairo : public NativeMetafile { public: - virtual ~PdfPsMetafile(); + virtual ~PdfMetafileCairo(); // NativeMetafile methods. virtual bool Init(); @@ -59,11 +59,11 @@ class PdfPsMetafile : public NativeMetafile { #endif // if defined(OS_CHROMEOS) protected: - PdfPsMetafile(); + PdfMetafileCairo(); private: friend class NativeMetafileFactory; - FRIEND_TEST_ALL_PREFIXES(PdfPsTest, Pdf); + FRIEND_TEST_ALL_PREFIXES(PdfMetafileCairoTest, Pdf); // Cleans up all resources. void CleanUpAll(); @@ -84,9 +84,9 @@ class PdfPsMetafile : public NativeMetafile { // initialized (Init() vs InitFromData()). std::string* current_data_; - DISALLOW_COPY_AND_ASSIGN(PdfPsMetafile); + DISALLOW_COPY_AND_ASSIGN(PdfMetafileCairo); }; } // namespace printing -#endif // PRINTING_PDF_PS_METAFILE_CAIRO_H_ +#endif // PRINTING_PDF_METAFILE_CAIRO_LINUX_H_ diff --git a/printing/pdf_ps_metafile_cairo_unittest.cc b/printing/pdf_metafile_cairo_linux_unittest.cc index 5b2bf2a..c644a3d 100644 --- a/printing/pdf_ps_metafile_cairo_unittest.cc +++ b/printing/pdf_metafile_cairo_linux_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "printing/pdf_ps_metafile_cairo.h" +#include "printing/pdf_metafile_cairo_linux.h" #include <fcntl.h> #include <string> @@ -20,15 +20,15 @@ typedef struct _cairo cairo_t; namespace { -class PdfPsTest : public testing::Test {}; +class PdfMetafileCairoTest : public testing::Test {}; } // namespace namespace printing { -TEST_F(PdfPsTest, Pdf) { +TEST_F(PdfMetafileCairoTest, Pdf) { // Tests in-renderer constructor. - printing::PdfPsMetafile pdf; + printing::PdfMetafileCairo pdf; EXPECT_TRUE(pdf.Init()); // Renders page 1. @@ -53,7 +53,7 @@ TEST_F(PdfPsTest, Pdf) { pdf.GetData(&buffer.front(), size); // Tests another constructor. - printing::PdfPsMetafile pdf2; + printing::PdfMetafileCairo pdf2; EXPECT_TRUE(pdf2.InitFromData(&buffer.front(), size)); // Tries to get the first 4 characters from pdf2. @@ -68,7 +68,7 @@ TEST_F(PdfPsTest, Pdf) { EXPECT_TRUE(pdf.SaveTo(FilePath("/dev/null"))); // Test overriding the metafile with raw data. - printing::PdfPsMetafile pdf3; + printing::PdfMetafileCairo pdf3; EXPECT_TRUE(pdf3.Init()); EXPECT_TRUE(pdf3.StartPage(gfx::Size(72, 73), gfx::Point(4, 5), 1)); std::string test_raw_data = "Dummy PDF"; diff --git a/printing/pdf_metafile_mac.cc b/printing/pdf_metafile_cg_mac.cc index 913f6aa..f1b387a 100644 --- a/printing/pdf_metafile_mac.cc +++ b/printing/pdf_metafile_cg_mac.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "printing/pdf_metafile_mac.h" +#include "printing/pdf_metafile_cg_mac.h" #include "base/file_path.h" #include "base/logging.h" @@ -15,13 +15,13 @@ using base::mac::ScopedCFTypeRef; namespace printing { -PdfMetafile::PdfMetafile() +PdfMetafileCg::PdfMetafileCg() : page_is_open_(false) { } -PdfMetafile::~PdfMetafile() {} +PdfMetafileCg::~PdfMetafileCg() {} -bool PdfMetafile::Init() { +bool PdfMetafileCg::Init() { // Ensure that Init hasn't already been called. DCHECK(!context_.get()); DCHECK(!pdf_data_.get()); @@ -47,7 +47,8 @@ bool PdfMetafile::Init() { return true; } -bool PdfMetafile::InitFromData(const void* src_buffer, uint32 src_buffer_size) { +bool PdfMetafileCg::InitFromData(const void* src_buffer, + uint32 src_buffer_size) { DCHECK(!context_.get()); DCHECK(!pdf_data_.get()); @@ -62,16 +63,16 @@ bool PdfMetafile::InitFromData(const void* src_buffer, uint32 src_buffer_size) { return true; } -skia::PlatformDevice* PdfMetafile::StartPageForVectorCanvas( +skia::PlatformDevice* PdfMetafileCg::StartPageForVectorCanvas( const gfx::Size& page_size, const gfx::Point& content_origin, const float& scale_factor) { NOTIMPLEMENTED(); return NULL; } -bool PdfMetafile::StartPage(const gfx::Size& page_size, - const gfx::Point& content_origin, - const float& scale_factor) { +bool PdfMetafileCg::StartPage(const gfx::Size& page_size, + const gfx::Point& content_origin, + const float& scale_factor) { DCHECK(context_.get()); DCHECK(!page_is_open_); @@ -93,7 +94,7 @@ bool PdfMetafile::StartPage(const gfx::Size& page_size, return context_.get() != NULL; } -bool PdfMetafile::FinishPage() { +bool PdfMetafileCg::FinishPage() { DCHECK(context_.get()); DCHECK(page_is_open_); @@ -103,7 +104,7 @@ bool PdfMetafile::FinishPage() { return true; } -bool PdfMetafile::FinishDocument() { +bool PdfMetafileCg::FinishDocument() { DCHECK(context_.get()); DCHECK(!page_is_open_); @@ -123,11 +124,13 @@ bool PdfMetafile::FinishDocument() { return true; } -bool PdfMetafile::RenderPage(unsigned int page_number, CGContextRef context, - const CGRect rect, bool shrink_to_fit, - bool stretch_to_fit, - bool center_horizontally, - bool center_vertically) const { +bool PdfMetafileCg::RenderPage(unsigned int page_number, + CGContextRef context, + const CGRect rect, + bool shrink_to_fit, + bool stretch_to_fit, + bool center_horizontally, + bool center_vertically) const { CGPDFDocumentRef pdf_doc = GetPDFDocument(); if (!pdf_doc) { LOG(ERROR) << "Unable to create PDF document from data"; @@ -175,12 +178,12 @@ bool PdfMetafile::RenderPage(unsigned int page_number, CGContextRef context, return true; } -unsigned int PdfMetafile::GetPageCount() const { +unsigned int PdfMetafileCg::GetPageCount() const { CGPDFDocumentRef pdf_doc = GetPDFDocument(); return pdf_doc ? CGPDFDocumentGetNumberOfPages(pdf_doc) : 0; } -gfx::Rect PdfMetafile::GetPageBounds(unsigned int page_number) const { +gfx::Rect PdfMetafileCg::GetPageBounds(unsigned int page_number) const { CGPDFDocumentRef pdf_doc = GetPDFDocument(); if (!pdf_doc) { LOG(ERROR) << "Unable to create PDF document from data"; @@ -195,7 +198,7 @@ gfx::Rect PdfMetafile::GetPageBounds(unsigned int page_number) const { return gfx::Rect(page_rect); } -uint32 PdfMetafile::GetDataSize() const { +uint32 PdfMetafileCg::GetDataSize() const { // PDF data is only valid/complete once the context is released. DCHECK(!context_); @@ -204,7 +207,7 @@ uint32 PdfMetafile::GetDataSize() const { return static_cast<uint32>(CFDataGetLength(pdf_data_)); } -bool PdfMetafile::GetData(void* dst_buffer, uint32 dst_buffer_size) const { +bool PdfMetafileCg::GetData(void* dst_buffer, uint32 dst_buffer_size) const { // PDF data is only valid/complete once the context is released. DCHECK(!context_); DCHECK(pdf_data_); @@ -221,7 +224,7 @@ bool PdfMetafile::GetData(void* dst_buffer, uint32 dst_buffer_size) const { return true; } -bool PdfMetafile::SaveTo(const FilePath& file_path) const { +bool PdfMetafileCg::SaveTo(const FilePath& file_path) const { DCHECK(pdf_data_.get()); DCHECK(!context_.get()); @@ -234,11 +237,11 @@ bool PdfMetafile::SaveTo(const FilePath& file_path) const { return error_code == 0; } -CGContextRef PdfMetafile::context() const { +CGContextRef PdfMetafileCg::context() const { return context_.get(); } -CGPDFDocumentRef PdfMetafile::GetPDFDocument() const { +CGPDFDocumentRef PdfMetafileCg::GetPDFDocument() const { // Make sure that we have data, and that it's not being modified any more. DCHECK(pdf_data_.get()); DCHECK(!context_.get()); diff --git a/printing/pdf_metafile_mac.h b/printing/pdf_metafile_cg_mac.h index 496b275..0183246 100644 --- a/printing/pdf_metafile_mac.h +++ b/printing/pdf_metafile_cg_mac.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef PRINTING_PDF_METAFILE_MAC_H_ -#define PRINTING_PDF_METAFILE_MAC_H_ +#ifndef PRINTING_PDF_METAFILE_CG_MAC_H_ +#define PRINTING_PDF_METAFILE_CG_MAC_H_ #include <ApplicationServices/ApplicationServices.h> #include <CoreFoundation/CoreFoundation.h> @@ -24,10 +24,10 @@ class Point; namespace printing { // This class creates a graphics context that renders into a PDF data stream. -class PdfMetafile : public NativeMetafile { +class PdfMetafileCg : public NativeMetafile { public: - virtual ~PdfMetafile(); + virtual ~PdfMetafileCg(); // NativeMetafile methods. virtual bool Init(); @@ -65,11 +65,11 @@ class PdfMetafile : public NativeMetafile { bool center_vertically) const; protected: - PdfMetafile(); + PdfMetafileCg(); private: friend class NativeMetafileFactory; - FRIEND_TEST_ALL_PREFIXES(PdfMetafileTest, Pdf); + FRIEND_TEST_ALL_PREFIXES(PdfMetafileCgTest, Pdf); // Returns a CGPDFDocumentRef version of pdf_data_. CGPDFDocumentRef GetPDFDocument() const; @@ -86,9 +86,9 @@ class PdfMetafile : public NativeMetafile { // Whether or not a page is currently open. bool page_is_open_; - DISALLOW_COPY_AND_ASSIGN(PdfMetafile); + DISALLOW_COPY_AND_ASSIGN(PdfMetafileCg); }; } // namespace printing -#endif // PRINTING_PDF_METAFILE_MAC_H_ +#endif // PRINTING_PDF_METAFILE_CG_MAC_H_ diff --git a/printing/pdf_metafile_mac_unittest.cc b/printing/pdf_metafile_cg_mac_unittest.cc index b237978..5324514 100644 --- a/printing/pdf_metafile_mac_unittest.cc +++ b/printing/pdf_metafile_cg_mac_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "printing/pdf_metafile_mac.h" +#include "printing/pdf_metafile_cg_mac.h" #import <ApplicationServices/ApplicationServices.h> @@ -14,9 +14,9 @@ namespace printing { -TEST(PdfMetafileTest, Pdf) { +TEST(PdfMetafileCgTest, Pdf) { // Test in-renderer constructor. - printing::PdfMetafile pdf; + printing::PdfMetafileCg pdf; EXPECT_TRUE(pdf.Init()); EXPECT_TRUE(pdf.context() != NULL); @@ -43,7 +43,7 @@ TEST(PdfMetafileTest, Pdf) { pdf.GetData(&buffer.front(), size); // Test browser-side constructor. - printing::PdfMetafile pdf2; + printing::PdfMetafileCg pdf2; EXPECT_TRUE(pdf2.InitFromData(&buffer.front(), size)); // Get the first 4 characters from pdf2. diff --git a/printing/print_settings_initializer_gtk.cc b/printing/print_settings_initializer_gtk.cc index 833db52..a42561ba 100644 --- a/printing/print_settings_initializer_gtk.cc +++ b/printing/print_settings_initializer_gtk.cc @@ -9,7 +9,6 @@ #include "base/string_piece.h" #include "base/utf_string_conversions.h" -#include "printing/pdf_ps_metafile_cairo.h" #include "printing/print_settings.h" #include "printing/units.h" diff --git a/printing/printing.gyp b/printing/printing.gyp index 94c90a6..ae61a41 100644 --- a/printing/printing.gyp +++ b/printing/printing.gyp @@ -47,10 +47,10 @@ 'page_range.h', 'page_setup.cc', 'page_setup.h', - 'pdf_metafile_mac.cc', - 'pdf_metafile_mac.h', - 'pdf_ps_metafile_cairo.cc', - 'pdf_ps_metafile_cairo.h', + 'pdf_metafile_cairo_linux.cc', + 'pdf_metafile_cairo_linux.h', + 'pdf_metafile_cg_mac.cc', + 'pdf_metafile_cg_mac.h', 'printed_document_cairo.cc', 'printed_document.cc', 'printed_document.h', @@ -165,8 +165,8 @@ 'page_overlays_unittest.cc', 'page_range_unittest.cc', 'page_setup_unittest.cc', - 'pdf_metafile_mac_unittest.cc', - 'pdf_ps_metafile_cairo_unittest.cc', + 'pdf_metafile_cairo_linux_unittest.cc', + 'pdf_metafile_cg_mac_unittest.cc', 'printed_page_unittest.cc', 'printing_context_win_unittest.cc', 'run_all_unittests.cc', diff --git a/skia/ext/platform_device_linux.h b/skia/ext/platform_device_linux.h index 17cb67f..e40934b 100644 --- a/skia/ext/platform_device_linux.h +++ b/skia/ext/platform_device_linux.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -27,7 +27,7 @@ class PlatformDevice : public SkDevice { protected: // Forwards |bitmap| to SkDevice's constructor. - PlatformDevice(const SkBitmap& bitmap); + explicit PlatformDevice(const SkBitmap& bitmap); }; } // namespace skia diff --git a/skia/ext/vector_canvas.cc b/skia/ext/vector_canvas.cc index 216a2ee..524ebbc 100644 --- a/skia/ext/vector_canvas.cc +++ b/skia/ext/vector_canvas.cc @@ -1,11 +1,9 @@ -// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. #include "skia/ext/vector_canvas.h" -#include "skia/ext/vector_platform_device.h" - namespace skia { VectorCanvas::VectorCanvas(PlatformDevice* device) diff --git a/skia/ext/vector_canvas_unittest.cc b/skia/ext/vector_canvas_unittest.cc index 355aa13..82deea2 100644 --- a/skia/ext/vector_canvas_unittest.cc +++ b/skia/ext/vector_canvas_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -14,7 +14,7 @@ #include "base/string_util.h" #include "base/utf_string_conversions.h" #include "skia/ext/vector_canvas.h" -#include "skia/ext/vector_platform_device.h" +#include "skia/ext/vector_platform_device_emf_win.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/skia/include/effects/SkDashPathEffect.h" #include "ui/gfx/codec/png_codec.h" @@ -388,7 +388,7 @@ class VectorCanvasTest : public ImageTest { size_ = size; context_ = new Context(); bitmap_ = new Bitmap(*context_, size_, size_); - vcanvas_ = new VectorCanvas(VectorPlatformDeviceFactory::CreateDevice( + vcanvas_ = new VectorCanvas(VectorPlatformDeviceEmfFactory::CreateDevice( size_, size_, true, context_->context())); pcanvas_ = new PlatformCanvas(size_, size_, false); @@ -455,7 +455,7 @@ TEST_F(VectorCanvasTest, Uninitialized) { context_ = new Context(); bitmap_ = new Bitmap(*context_, size_, size_); - vcanvas_ = new VectorCanvas(VectorPlatformDeviceFactory::CreateDevice( + vcanvas_ = new VectorCanvas(VectorPlatformDeviceEmfFactory::CreateDevice( size_, size_, true, context_->context())); pcanvas_ = new PlatformCanvas(size_, size_, false); diff --git a/skia/ext/vector_platform_device.h b/skia/ext/vector_platform_device.h deleted file mode 100644 index 1b699d4..0000000 --- a/skia/ext/vector_platform_device.h +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2009 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. - -#ifndef SKIA_EXT_VECTOR_PLATFORM_DEVICE_H_ -#define SKIA_EXT_VECTOR_PLATFORM_DEVICE_H_ -#pragma once - -// This file provides an easy way to include the appropriate -// VectorPlatformDevice header file for your platform. -#if defined(WIN32) -#include "skia/ext/vector_platform_device_win.h" -#elif defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__) -#include "skia/ext/vector_platform_device_linux.h" -#elif defined(__APPLE__) -#include "skia/ext/bitmap_platform_device_mac.h" -namespace skia { -typedef BitmapPlatformDeviceFactory VectorPlatformDeviceFactory; -} // namespace skia -#endif - -#endif - diff --git a/skia/ext/vector_platform_device_linux.cc b/skia/ext/vector_platform_device_cairo_linux.cc index bc6a41e..ba79a2b 100644 --- a/skia/ext/vector_platform_device_linux.cc +++ b/skia/ext/vector_platform_device_cairo_linux.cc @@ -1,8 +1,8 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. -#include "skia/ext/vector_platform_device.h" +#include "skia/ext/vector_platform_device_cairo_linux.h" #include <cairo.h> #include <cairo-ft.h> @@ -40,7 +40,7 @@ class FtLibrary { FT_Error ft_error = FT_Init_FreeType(&library_); if (ft_error) { DLOG(ERROR) << "Cannot initialize FreeType library for " \ - << "VectorPlatformDevice."; + << "VectorPlatformDeviceCairo."; } } @@ -68,19 +68,20 @@ bool IsContextValid(cairo_t* context) { namespace skia { -SkDevice* VectorPlatformDeviceFactory::newDevice(SkCanvas* ignored, - SkBitmap::Config config, - int width, int height, - bool isOpaque, - bool isForLayer) { +SkDevice* VectorPlatformDeviceCairoFactory::newDevice(SkCanvas* ignored, + SkBitmap::Config config, + int width, int height, + bool isOpaque, + bool isForLayer) { SkASSERT(config == SkBitmap::kARGB_8888_Config); return CreateDevice(NULL, width, height, isOpaque); } // static -PlatformDevice* VectorPlatformDeviceFactory::CreateDevice(cairo_t* context, - int width, int height, - bool isOpaque) { +PlatformDevice* VectorPlatformDeviceCairoFactory::CreateDevice(cairo_t* context, + int width, + int height, + bool isOpaque) { // TODO(myhuang): Here we might also have similar issues as those on Windows // (vector_canvas_win.cc, http://crbug.com/18382 & http://crbug.com/18383). // Please note that is_opaque is true when we use this class for printing. @@ -90,12 +91,14 @@ PlatformDevice* VectorPlatformDeviceFactory::CreateDevice(cairo_t* context, } PlatformDevice* device = - VectorPlatformDevice::create(context, width, height); + VectorPlatformDeviceCairo::create(context, width, height); return device; } -VectorPlatformDevice* VectorPlatformDevice::create(PlatformSurface context, - int width, int height) { +VectorPlatformDeviceCairo* VectorPlatformDeviceCairo::create( + PlatformSurface context, + int width, + int height) { SkASSERT(cairo_status(context) == CAIRO_STATUS_SUCCESS); SkASSERT(width > 0); SkASSERT(height > 0); @@ -106,11 +109,11 @@ VectorPlatformDevice* VectorPlatformDevice::create(PlatformSurface context, SkBitmap bitmap; bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height); - return new VectorPlatformDevice(context, bitmap); + return new VectorPlatformDeviceCairo(context, bitmap); } -VectorPlatformDevice::VectorPlatformDevice(PlatformSurface context, - const SkBitmap& bitmap) +VectorPlatformDeviceCairo::VectorPlatformDeviceCairo(PlatformSurface context, + const SkBitmap& bitmap) : PlatformDevice(bitmap), context_(context) { SkASSERT(bitmap.getConfig() == SkBitmap::kARGB_8888_Config); @@ -121,28 +124,29 @@ VectorPlatformDevice::VectorPlatformDevice(PlatformSurface context, transform_.reset(); } -VectorPlatformDevice::~VectorPlatformDevice() { +VectorPlatformDeviceCairo::~VectorPlatformDeviceCairo() { // Un-ref |context_| since we referenced it in the constructor. cairo_destroy(context_); } -SkDeviceFactory* VectorPlatformDevice::getDeviceFactory() { - return SkNEW(VectorPlatformDeviceFactory); +SkDeviceFactory* VectorPlatformDeviceCairo::getDeviceFactory() { + return SkNEW(VectorPlatformDeviceCairoFactory); } -bool VectorPlatformDevice::IsVectorial() { +bool VectorPlatformDeviceCairo::IsVectorial() { return true; } -PlatformDevice::PlatformSurface VectorPlatformDevice::beginPlatformPaint() { +PlatformDevice::PlatformSurface +VectorPlatformDeviceCairo::beginPlatformPaint() { return context_; } -void VectorPlatformDevice::drawBitmap(const SkDraw& draw, - const SkBitmap& bitmap, - const SkIRect* srcRectOrNull, - const SkMatrix& matrix, - const SkPaint& paint) { +void VectorPlatformDeviceCairo::drawBitmap(const SkDraw& draw, + const SkBitmap& bitmap, + const SkIRect* srcRectOrNull, + const SkMatrix& matrix, + const SkPaint& paint) { SkASSERT(bitmap.getConfig() == SkBitmap::kARGB_8888_Config); // Load the temporary matrix. This is what will translate, rotate and resize @@ -157,19 +161,19 @@ void VectorPlatformDevice::drawBitmap(const SkDraw& draw, LoadTransformToContext(transform_); } -void VectorPlatformDevice::drawDevice(const SkDraw& draw, - SkDevice* device, - int x, - int y, - const SkPaint& paint) { +void VectorPlatformDeviceCairo::drawDevice(const SkDraw& draw, + SkDevice* device, + int x, + int y, + const SkPaint& paint) { SkASSERT(device); // TODO(myhuang): We may also have to consider http://b/1183870 . drawSprite(draw, device->accessBitmap(false), x, y, paint); } -void VectorPlatformDevice::drawPaint(const SkDraw& draw, - const SkPaint& paint) { +void VectorPlatformDeviceCairo::drawPaint(const SkDraw& draw, + const SkPaint& paint) { // Bypass the current transformation matrix. LoadIdentityTransformToContext(); @@ -185,11 +189,11 @@ void VectorPlatformDevice::drawPaint(const SkDraw& draw, LoadTransformToContext(transform_); } -void VectorPlatformDevice::drawPath(const SkDraw& draw, - const SkPath& path, - const SkPaint& paint, - const SkMatrix* prePathMatrix, - bool pathIsMutable) { +void VectorPlatformDeviceCairo::drawPath(const SkDraw& draw, + const SkPath& path, + const SkPaint& paint, + const SkMatrix* prePathMatrix, + bool pathIsMutable) { if (paint.getPathEffect()) { // Apply the path effect forehand. SkPath path_modified; @@ -273,11 +277,11 @@ void VectorPlatformDevice::drawPath(const SkDraw& draw, DoPaintStyle(paint); } -void VectorPlatformDevice::drawPoints(const SkDraw& draw, - SkCanvas::PointMode mode, - size_t count, - const SkPoint pts[], - const SkPaint& paint) { +void VectorPlatformDeviceCairo::drawPoints(const SkDraw& draw, + SkCanvas::PointMode mode, + size_t count, + const SkPoint pts[], + const SkPaint& paint) { SkASSERT(pts); if (!count) @@ -339,13 +343,13 @@ void VectorPlatformDevice::drawPoints(const SkDraw& draw, // TODO(myhuang): Embed fonts/texts into PDF surface. // Please NOTE that len records text's length in byte, not uint16_t. -void VectorPlatformDevice::drawPosText(const SkDraw& draw, - const void* text, - size_t len, - const SkScalar pos[], - SkScalar constY, - int scalarsPerPos, - const SkPaint& paint) { +void VectorPlatformDeviceCairo::drawPosText(const SkDraw& draw, + const void* text, + size_t len, + const SkScalar pos[], + SkScalar constY, + int scalarsPerPos, + const SkPaint& paint) { SkASSERT(text); SkASSERT(pos); SkASSERT(paint.getTextEncoding() == SkPaint::kGlyphID_TextEncoding); @@ -399,9 +403,9 @@ void VectorPlatformDevice::drawPosText(const SkDraw& draw, } } -void VectorPlatformDevice::drawRect(const SkDraw& draw, - const SkRect& rect, - const SkPaint& paint) { +void VectorPlatformDeviceCairo::drawRect(const SkDraw& draw, + const SkRect& rect, + const SkPaint& paint) { if (paint.getPathEffect()) { // Draw a path instead. SkPath path_orginal; @@ -434,10 +438,10 @@ void VectorPlatformDevice::drawRect(const SkDraw& draw, DoPaintStyle(paint); } -void VectorPlatformDevice::drawSprite(const SkDraw& draw, - const SkBitmap& bitmap, - int x, int y, - const SkPaint& paint) { +void VectorPlatformDeviceCairo::drawSprite(const SkDraw& draw, + const SkBitmap& bitmap, + int x, int y, + const SkPaint& paint) { SkASSERT(bitmap.getConfig() == SkBitmap::kARGB_8888_Config); LoadIdentityTransformToContext(); @@ -448,44 +452,44 @@ void VectorPlatformDevice::drawSprite(const SkDraw& draw, LoadTransformToContext(transform_); } -void VectorPlatformDevice::drawText(const SkDraw& draw, - const void* text, - size_t byteLength, - SkScalar x, - SkScalar y, - const SkPaint& paint) { +void VectorPlatformDeviceCairo::drawText(const SkDraw& draw, + const void* text, + size_t byteLength, + SkScalar x, + SkScalar y, + const SkPaint& paint) { // This function isn't used in the code. Verify this assumption. SkASSERT(false); } -void VectorPlatformDevice::drawTextOnPath(const SkDraw& draw, - const void* text, - size_t len, - const SkPath& path, - const SkMatrix* matrix, - const SkPaint& paint) { +void VectorPlatformDeviceCairo::drawTextOnPath(const SkDraw& draw, + const void* text, + size_t len, + const SkPath& path, + const SkMatrix* matrix, + const SkPaint& paint) { // This function isn't used in the code. Verify this assumption. SkASSERT(false); } -void VectorPlatformDevice::drawVertices(const SkDraw& draw, - SkCanvas::VertexMode vmode, - int vertexCount, - const SkPoint vertices[], - const SkPoint texs[], - const SkColor colors[], - SkXfermode* xmode, - const uint16_t indices[], - int indexCount, - const SkPaint& paint) { +void VectorPlatformDeviceCairo::drawVertices(const SkDraw& draw, + SkCanvas::VertexMode vmode, + int vertexCount, + const SkPoint vertices[], + const SkPoint texs[], + const SkColor colors[], + SkXfermode* xmode, + const uint16_t indices[], + int indexCount, + const SkPaint& paint) { // This function isn't used in the code. Verify this assumption. SkASSERT(false); } -void VectorPlatformDevice::setMatrixClip(const SkMatrix& transform, - const SkRegion& region, - const SkClipStack&) { +void VectorPlatformDeviceCairo::setMatrixClip(const SkMatrix& transform, + const SkRegion& region, + const SkClipStack&) { clip_region_ = region; if (!clip_region_.isEmpty()) LoadClipRegion(clip_region_); @@ -494,7 +498,7 @@ void VectorPlatformDevice::setMatrixClip(const SkMatrix& transform, LoadTransformToContext(transform_); } -void VectorPlatformDevice::ApplyPaintColor(const SkPaint& paint) { +void VectorPlatformDeviceCairo::ApplyPaintColor(const SkPaint& paint) { SkColor color = paint.getColor(); double a = static_cast<double>(SkColorGetA(color)) / 255.; double r = static_cast<double>(SkColorGetR(color)) / 255.; @@ -504,14 +508,14 @@ void VectorPlatformDevice::ApplyPaintColor(const SkPaint& paint) { cairo_set_source_rgba(context_, r, g, b, a); } -void VectorPlatformDevice::ApplyFillStyle(const SkPath& path) { +void VectorPlatformDeviceCairo::ApplyFillStyle(const SkPath& path) { // Setup fill style. // TODO(myhuang): Cairo does NOT support all skia fill rules!! cairo_set_fill_rule(context_, static_cast<cairo_fill_rule_t>(path.getFillType())); } -void VectorPlatformDevice::ApplyStrokeStyle(const SkPaint& paint) { +void VectorPlatformDeviceCairo::ApplyStrokeStyle(const SkPaint& paint) { // Line width. cairo_set_line_width(context_, paint.getStrokeWidth()); @@ -524,7 +528,7 @@ void VectorPlatformDevice::ApplyStrokeStyle(const SkPaint& paint) { static_cast<cairo_line_cap_t>(paint.getStrokeCap())); } -void VectorPlatformDevice::DoPaintStyle(const SkPaint& paint) { +void VectorPlatformDeviceCairo::DoPaintStyle(const SkPaint& paint) { SkPaint::Style style = paint.getStyle(); switch (style) { @@ -546,9 +550,9 @@ void VectorPlatformDevice::DoPaintStyle(const SkPaint& paint) { } } -void VectorPlatformDevice::InternalDrawBitmap(const SkBitmap& bitmap, - int x, int y, - const SkPaint& paint) { +void VectorPlatformDeviceCairo::InternalDrawBitmap(const SkBitmap& bitmap, + int x, int y, + const SkPaint& paint) { SkASSERT(bitmap.getConfig() == SkBitmap::kARGB_8888_Config); unsigned char alpha = paint.getAlpha(); @@ -575,7 +579,7 @@ void VectorPlatformDevice::InternalDrawBitmap(const SkBitmap& bitmap, cairo_surface_destroy(bitmap_surface); } -void VectorPlatformDevice::LoadClipRegion(const SkRegion& clip) { +void VectorPlatformDeviceCairo::LoadClipRegion(const SkRegion& clip) { cairo_reset_clip(context_); LoadIdentityTransformToContext(); @@ -591,13 +595,13 @@ void VectorPlatformDevice::LoadClipRegion(const SkRegion& clip) { LoadTransformToContext(transform_); } -void VectorPlatformDevice::LoadIdentityTransformToContext() { +void VectorPlatformDeviceCairo::LoadIdentityTransformToContext() { SkMatrix identity; identity.reset(); LoadTransformToContext(identity); } -void VectorPlatformDevice::LoadTransformToContext(const SkMatrix& matrix) { +void VectorPlatformDeviceCairo::LoadTransformToContext(const SkMatrix& matrix) { cairo_matrix_t m; m.xx = matrix[SkMatrix::kMScaleX]; m.xy = matrix[SkMatrix::kMSkewX]; @@ -608,7 +612,7 @@ void VectorPlatformDevice::LoadTransformToContext(const SkMatrix& matrix) { cairo_set_matrix(context_, &m); } -bool VectorPlatformDevice::SelectFontById(uint32_t font_id) { +bool VectorPlatformDeviceCairo::SelectFontById(uint32_t font_id) { DCHECK(IsContextValid(context_)); DCHECK(SkFontHost::ValidFontID(font_id)); @@ -686,7 +690,7 @@ bool VectorPlatformDevice::SelectFontById(uint32_t font_id) { } // static -void VectorPlatformDevice::ClearFontCache() { +void VectorPlatformDeviceCairo::ClearFontCache() { MapFontId2FontInfo* g_font_cache = g_map_font_id_to_font_info.Pointer(); DCHECK(g_font_cache); diff --git a/skia/ext/vector_platform_device_linux.h b/skia/ext/vector_platform_device_cairo_linux.h index ae2bafb..29c4b95 100644 --- a/skia/ext/vector_platform_device_linux.h +++ b/skia/ext/vector_platform_device_cairo_linux.h @@ -2,10 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef SKIA_EXT_VECTOR_PLATFORM_DEVICE_LINUX_H_ -#define SKIA_EXT_VECTOR_PLATFORM_DEVICE_LINUX_H_ +#ifndef SKIA_EXT_VECTOR_PLATFORM_DEVICE_CAIRO_LINUX_H_ +#define SKIA_EXT_VECTOR_PLATFORM_DEVICE_CAIRO_LINUX_H_ #pragma once +#include "base/basictypes.h" #include "base/compiler_specific.h" #include "skia/ext/platform_device.h" #include "third_party/skia/include/core/SkMatrix.h" @@ -13,7 +14,7 @@ namespace skia { -class VectorPlatformDeviceFactory : public SkDeviceFactory { +class VectorPlatformDeviceCairoFactory : public SkDeviceFactory { public: static PlatformDevice* CreateDevice(cairo_t* context, int width, int height, bool isOpaque); @@ -29,17 +30,17 @@ class VectorPlatformDeviceFactory : public SkDeviceFactory { // cooresponding Cairo APIs and outputs to a Cairo surface. Please NOTE that // since it is completely vectorial, the bitmap content in it is thus // meaningless. -class VectorPlatformDevice : public PlatformDevice { +class VectorPlatformDeviceCairo : public PlatformDevice { public: - virtual ~VectorPlatformDevice(); + virtual ~VectorPlatformDeviceCairo(); // Factory function. Ownership of |context| is not transferred. - static VectorPlatformDevice* create(PlatformSurface context, - int width, int height); + static VectorPlatformDeviceCairo* create(PlatformSurface context, + int width, int height); // Clean up cached fonts. It is an error to call this while some - // VectorPlatformDevice callee is still using fonts created for it by this - // class. + // VectorPlatformDeviceCairo callee is still using fonts created for it by + // this class. static void ClearFontCache(); // Overridden from SkDevice (through PlatformDevice): @@ -85,8 +86,8 @@ class VectorPlatformDevice : public PlatformDevice { virtual bool IsVectorial(); protected: - explicit VectorPlatformDevice(PlatformSurface context, - const SkBitmap& bitmap); + explicit VectorPlatformDeviceCairo(PlatformSurface context, + const SkBitmap& bitmap); private: // Apply paint's color in the context. @@ -129,11 +130,9 @@ class VectorPlatformDevice : public PlatformDevice { // Device context. PlatformSurface context_; - // Copy & assign are not supported. - VectorPlatformDevice(const VectorPlatformDevice&); - const VectorPlatformDevice& operator=(const VectorPlatformDevice&); + DISALLOW_COPY_AND_ASSIGN(VectorPlatformDeviceCairo); }; } // namespace skia -#endif // SKIA_EXT_VECTOR_PLATFORM_DEVICE_LINUX_H_ +#endif // SKIA_EXT_VECTOR_PLATFORM_DEVICE_CAIRO_LINUX_H_ diff --git a/skia/ext/vector_platform_device_win.cc b/skia/ext/vector_platform_device_emf_win.cc index 90f824e..d86ad3d 100644 --- a/skia/ext/vector_platform_device_win.cc +++ b/skia/ext/vector_platform_device_emf_win.cc @@ -1,10 +1,10 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. #include <windows.h> -#include "skia/ext/vector_platform_device_win.h" +#include "skia/ext/vector_platform_device_emf_win.h" #include "skia/ext/bitmap_platform_device.h" #include "skia/ext/skia_utils_win.h" @@ -12,17 +12,17 @@ namespace skia { -SkDevice* VectorPlatformDeviceFactory::newDevice(SkCanvas* unused, - SkBitmap::Config config, - int width, int height, - bool isOpaque, - bool isForLayer) { +SkDevice* VectorPlatformDeviceEmfFactory::newDevice(SkCanvas* unused, + SkBitmap::Config config, + int width, int height, + bool isOpaque, + bool isForLayer) { SkASSERT(config == SkBitmap::kARGB_8888_Config); return CreateDevice(width, height, isOpaque, NULL); } //static -PlatformDevice* VectorPlatformDeviceFactory::CreateDevice( +PlatformDevice* VectorPlatformDeviceEmfFactory::CreateDevice( int width, int height, bool is_opaque, HANDLE shared_section) { if (!is_opaque) { // TODO(maruel): http://crbug.com/18382 When restoring a semi-transparent @@ -33,8 +33,8 @@ PlatformDevice* VectorPlatformDeviceFactory::CreateDevice( // EMF-based VectorDevice and have this device registers the drawing. When // playing back the device into a bitmap, do it at the printer's dpi instead // of the layout's dpi (which is much lower). - return BitmapPlatformDevice::create(width, height, - is_opaque, shared_section); + return BitmapPlatformDevice::create(width, height, is_opaque, + shared_section); } // TODO(maruel): http://crbug.com/18383 Look if it would be worth to @@ -46,7 +46,7 @@ PlatformDevice* VectorPlatformDeviceFactory::CreateDevice( // SkScalarRound(value) as SkScalarRound(value * 10). Safari is already // doing the same for text rendering. SkASSERT(shared_section); - PlatformDevice* device = VectorPlatformDevice::create( + PlatformDevice* device = VectorPlatformDeviceEmf::create( reinterpret_cast<HDC>(shared_section), width, height); return device; } @@ -65,8 +65,9 @@ static void FillBitmapInfoHeader(int width, int height, BITMAPINFOHEADER* hdr) { hdr->biClrImportant = 0; } -VectorPlatformDevice* VectorPlatformDevice::create(HDC dc, - int width, int height) { +VectorPlatformDeviceEmf* VectorPlatformDeviceEmf::create(HDC dc, + int width, + int height) { InitializeDC(dc); // Link the SkBitmap to the current selected bitmap in the device context. @@ -79,8 +80,9 @@ VectorPlatformDevice* VectorPlatformDevice::create(HDC dc, sizeof(BITMAP)) { // The context has a bitmap attached. Attach our SkBitmap to it. // Warning: If the bitmap gets unselected from the HDC, - // VectorPlatformDevice has no way to detect this, so the HBITMAP could be - // released while SkBitmap still has a reference to it. Be cautious. + // VectorPlatformDeviceEmf has no way to detect this, so the HBITMAP + // could be released while SkBitmap still has a reference to it. Be + // cautious. if (width == bitmap_data.bmWidth && height == bitmap_data.bmHeight) { bitmap.setConfig(SkBitmap::kARGB_8888_Config, @@ -96,10 +98,10 @@ VectorPlatformDevice* VectorPlatformDevice::create(HDC dc, if (!succeeded) bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height); - return new VectorPlatformDevice(dc, bitmap); + return new VectorPlatformDeviceEmf(dc, bitmap); } -VectorPlatformDevice::VectorPlatformDevice(HDC dc, const SkBitmap& bitmap) +VectorPlatformDeviceEmf::VectorPlatformDeviceEmf(HDC dc, const SkBitmap& bitmap) : PlatformDevice(bitmap), hdc_(dc), previous_brush_(NULL), @@ -108,13 +110,14 @@ VectorPlatformDevice::VectorPlatformDevice(HDC dc, const SkBitmap& bitmap) transform_.reset(); } -VectorPlatformDevice::~VectorPlatformDevice() { +VectorPlatformDeviceEmf::~VectorPlatformDeviceEmf() { SkASSERT(previous_brush_ == NULL); SkASSERT(previous_pen_ == NULL); } -void VectorPlatformDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) { +void VectorPlatformDeviceEmf::drawPaint(const SkDraw& draw, + const SkPaint& paint) { // TODO(maruel): Bypass the current transformation matrix. SkRect rect; rect.fLeft = 0; @@ -124,11 +127,11 @@ void VectorPlatformDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) { drawRect(draw, rect, paint); } -void VectorPlatformDevice::drawPoints(const SkDraw& draw, - SkCanvas::PointMode mode, - size_t count, - const SkPoint pts[], - const SkPaint& paint) { +void VectorPlatformDeviceEmf::drawPoints(const SkDraw& draw, + SkCanvas::PointMode mode, + size_t count, + const SkPoint pts[], + const SkPaint& paint) { if (!count) return; @@ -167,9 +170,9 @@ void VectorPlatformDevice::drawPoints(const SkDraw& draw, drawPath(draw, path, tmp_paint); } -void VectorPlatformDevice::drawRect(const SkDraw& draw, - const SkRect& rect, - const SkPaint& paint) { +void VectorPlatformDeviceEmf::drawRect(const SkDraw& draw, + const SkRect& rect, + const SkPaint& paint) { if (paint.getPathEffect()) { // Draw a path instead. SkPath path_orginal; @@ -201,11 +204,11 @@ void VectorPlatformDevice::drawRect(const SkDraw& draw, Cleanup(); } -void VectorPlatformDevice::drawPath(const SkDraw& draw, - const SkPath& path, - const SkPaint& paint, - const SkMatrix* prePathMatrix, - bool pathIsMutable) { +void VectorPlatformDeviceEmf::drawPath(const SkDraw& draw, + const SkPath& path, + const SkPaint& paint, + const SkMatrix* prePathMatrix, + bool pathIsMutable) { if (paint.getPathEffect()) { // Apply the path effect forehand. SkPath path_modified; @@ -248,11 +251,11 @@ void VectorPlatformDevice::drawPath(const SkDraw& draw, Cleanup(); } -void VectorPlatformDevice::drawBitmap(const SkDraw& draw, - const SkBitmap& bitmap, - const SkIRect* srcRectOrNull, - const SkMatrix& matrix, - const SkPaint& paint) { +void VectorPlatformDeviceEmf::drawBitmap(const SkDraw& draw, + const SkBitmap& bitmap, + const SkIRect* srcRectOrNull, + const SkMatrix& matrix, + const SkPaint& paint) { // Load the temporary matrix. This is what will translate, rotate and resize // the bitmap. SkMatrix actual_transform(transform_); @@ -265,10 +268,10 @@ void VectorPlatformDevice::drawBitmap(const SkDraw& draw, LoadTransformToDC(hdc_, transform_); } -void VectorPlatformDevice::drawSprite(const SkDraw& draw, - const SkBitmap& bitmap, - int x, int y, - const SkPaint& paint) { +void VectorPlatformDeviceEmf::drawSprite(const SkDraw& draw, + const SkBitmap& bitmap, + int x, int y, + const SkPaint& paint) { SkMatrix identity; identity.reset(); LoadTransformToDC(hdc_, identity); @@ -279,62 +282,62 @@ void VectorPlatformDevice::drawSprite(const SkDraw& draw, LoadTransformToDC(hdc_, transform_); } -void VectorPlatformDevice::drawText(const SkDraw& draw, - const void* text, - size_t byteLength, - SkScalar x, - SkScalar y, - const SkPaint& paint) { - // This function isn't used in the code. Verify this assumption. - SkASSERT(false); -} - -void VectorPlatformDevice::drawPosText(const SkDraw& draw, +void VectorPlatformDeviceEmf::drawText(const SkDraw& draw, const void* text, - size_t len, - const SkScalar pos[], - SkScalar constY, - int scalarsPerPos, + size_t byteLength, + SkScalar x, + SkScalar y, const SkPaint& paint) { // This function isn't used in the code. Verify this assumption. SkASSERT(false); } -void VectorPlatformDevice::drawTextOnPath(const SkDraw& draw, +void VectorPlatformDeviceEmf::drawPosText(const SkDraw& draw, const void* text, size_t len, - const SkPath& path, - const SkMatrix* matrix, + const SkScalar pos[], + SkScalar constY, + int scalarsPerPos, const SkPaint& paint) { // This function isn't used in the code. Verify this assumption. SkASSERT(false); } -void VectorPlatformDevice::drawVertices(const SkDraw& draw, - SkCanvas::VertexMode vmode, - int vertexCount, - const SkPoint vertices[], - const SkPoint texs[], - const SkColor colors[], - SkXfermode* xmode, - const uint16_t indices[], - int indexCount, - const SkPaint& paint) { +void VectorPlatformDeviceEmf::drawTextOnPath(const SkDraw& draw, + const void* text, + size_t len, + const SkPath& path, + const SkMatrix* matrix, + const SkPaint& paint) { + // This function isn't used in the code. Verify this assumption. + SkASSERT(false); +} + +void VectorPlatformDeviceEmf::drawVertices(const SkDraw& draw, + SkCanvas::VertexMode vmode, + int vertexCount, + const SkPoint vertices[], + const SkPoint texs[], + const SkColor colors[], + SkXfermode* xmode, + const uint16_t indices[], + int indexCount, + const SkPaint& paint) { // This function isn't used in the code. Verify this assumption. SkASSERT(false); } -void VectorPlatformDevice::drawDevice(const SkDraw& draw, - SkDevice* device, - int x, - int y, - const SkPaint& paint) { +void VectorPlatformDeviceEmf::drawDevice(const SkDraw& draw, + SkDevice* device, + int x, + int y, + const SkPaint& paint) { // TODO(maruel): http://b/1183870 Playback the EMF buffer at printer's dpi if // it is a vectorial device. drawSprite(draw, device->accessBitmap(false), x, y, paint); } -bool VectorPlatformDevice::ApplyPaint(const SkPaint& paint) { +bool VectorPlatformDeviceEmf::ApplyPaint(const SkPaint& paint) { // Note: The goal here is to transfert the SkPaint's state to the HDC's state. // This function does not execute the SkPaint drawing commands. These should // be executed in drawPaint(). @@ -413,9 +416,9 @@ bool VectorPlatformDevice::ApplyPaint(const SkPaint& paint) { return true; } -void VectorPlatformDevice::setMatrixClip(const SkMatrix& transform, - const SkRegion& region, - const SkClipStack&) { +void VectorPlatformDeviceEmf::setMatrixClip(const SkMatrix& transform, + const SkRegion& region, + const SkClipStack&) { transform_ = transform; LoadTransformToDC(hdc_, transform_); clip_region_ = region; @@ -423,18 +426,18 @@ void VectorPlatformDevice::setMatrixClip(const SkMatrix& transform, LoadClipRegion(); } -void VectorPlatformDevice::drawToHDC(HDC dc, int x, int y, - const RECT* src_rect) { +void VectorPlatformDeviceEmf::drawToHDC(HDC dc, int x, int y, + const RECT* src_rect) { SkASSERT(false); } -void VectorPlatformDevice::LoadClipRegion() { +void VectorPlatformDeviceEmf::LoadClipRegion() { SkMatrix t; t.reset(); LoadClippingRegionToDC(hdc_, clip_region_, t); } -bool VectorPlatformDevice::CreateBrush(bool use_brush, COLORREF color) { +bool VectorPlatformDeviceEmf::CreateBrush(bool use_brush, COLORREF color) { SkASSERT(previous_brush_ == NULL); // We can't use SetDCBrushColor() or DC_BRUSH when drawing to a EMF buffer. // SetDCBrushColor() calls are not recorded at all and DC_BRUSH will use @@ -463,11 +466,11 @@ bool VectorPlatformDevice::CreateBrush(bool use_brush, COLORREF color) { return previous_brush_ != NULL; } -bool VectorPlatformDevice::CreatePen(bool use_pen, - COLORREF color, - int stroke_width, - float stroke_miter, - DWORD pen_style) { +bool VectorPlatformDeviceEmf::CreatePen(bool use_pen, + COLORREF color, + int stroke_width, + float stroke_miter, + DWORD pen_style) { SkASSERT(previous_pen_ == NULL); // We can't use SetDCPenColor() or DC_PEN when drawing to a EMF buffer. // SetDCPenColor() calls are not recorded at all and DC_PEN will use BLACK_PEN @@ -504,7 +507,7 @@ bool VectorPlatformDevice::CreatePen(bool use_pen, return true; } -void VectorPlatformDevice::Cleanup() { +void VectorPlatformDeviceEmf::Cleanup() { if (previous_brush_) { HGDIOBJ result = SelectObject(previous_brush_); previous_brush_ = NULL; @@ -525,7 +528,7 @@ void VectorPlatformDevice::Cleanup() { AbortPath(hdc_); } -HGDIOBJ VectorPlatformDevice::SelectObject(HGDIOBJ object) { +HGDIOBJ VectorPlatformDeviceEmf::SelectObject(HGDIOBJ object) { HGDIOBJ result = ::SelectObject(hdc_, object); SkASSERT(result != HGDI_ERROR); if (result == HGDI_ERROR) @@ -533,7 +536,8 @@ HGDIOBJ VectorPlatformDevice::SelectObject(HGDIOBJ object) { return result; } -bool VectorPlatformDevice::CreateBrush(bool use_brush, const SkPaint& paint) { +bool VectorPlatformDeviceEmf::CreateBrush(bool use_brush, + const SkPaint& paint) { // Make sure that for transparent color, no brush is used. if (paint.getAlpha() == 0) { use_brush = false; @@ -542,7 +546,7 @@ bool VectorPlatformDevice::CreateBrush(bool use_brush, const SkPaint& paint) { return CreateBrush(use_brush, SkColorToCOLORREF(paint.getColor())); } -bool VectorPlatformDevice::CreatePen(bool use_pen, const SkPaint& paint) { +bool VectorPlatformDeviceEmf::CreatePen(bool use_pen, const SkPaint& paint) { // Make sure that for transparent color, no pen is used. if (paint.getAlpha() == 0) { use_pen = false; @@ -591,9 +595,9 @@ bool VectorPlatformDevice::CreatePen(bool use_pen, const SkPaint& paint) { pen_style); } -void VectorPlatformDevice::InternalDrawBitmap(const SkBitmap& bitmap, - int x, int y, - const SkPaint& paint) { +void VectorPlatformDeviceEmf::InternalDrawBitmap(const SkBitmap& bitmap, + int x, int y, + const SkPaint& paint) { unsigned char alpha = paint.getAlpha(); if (alpha == 0) return; diff --git a/skia/ext/vector_platform_device_win.h b/skia/ext/vector_platform_device_emf_win.h index 83d51f7..72fd90a 100644 --- a/skia/ext/vector_platform_device_win.h +++ b/skia/ext/vector_platform_device_emf_win.h @@ -1,11 +1,12 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. -#ifndef SKIA_EXT_VECTOR_PLATFORM_DEVICE_WIN_H_ -#define SKIA_EXT_VECTOR_PLATFORM_DEVICE_WIN_H_ +#ifndef SKIA_EXT_VECTOR_PLATFORM_DEVICE_EMF_WIN_H_ +#define SKIA_EXT_VECTOR_PLATFORM_DEVICE_EMF_WIN_H_ #pragma once +#include "base/basictypes.h" #include "base/compiler_specific.h" #include "skia/ext/platform_device.h" #include "third_party/skia/include/core/SkMatrix.h" @@ -13,7 +14,7 @@ namespace skia { -class SK_API VectorPlatformDeviceFactory : public SkDeviceFactory { +class SK_API VectorPlatformDeviceEmfFactory : public SkDeviceFactory { public: virtual SkDevice* newDevice(SkCanvas* ignored, SkBitmap::Config config, int width, int height, @@ -26,16 +27,16 @@ class SK_API VectorPlatformDeviceFactory : public SkDeviceFactory { // SkCanvas to draw into. This specific device is not not backed by a surface // and is thus unreadable. This is because the backend is completely vectorial. // This device is a simple wrapper over a Windows device context (HDC) handle. -class VectorPlatformDevice : public PlatformDevice { +class VectorPlatformDeviceEmf : public PlatformDevice { public: // Factory function. The DC is kept as the output context. - static VectorPlatformDevice* create(HDC dc, int width, int height); + static VectorPlatformDeviceEmf* create(HDC dc, int width, int height); - VectorPlatformDevice(HDC dc, const SkBitmap& bitmap); - virtual ~VectorPlatformDevice(); + VectorPlatformDeviceEmf(HDC dc, const SkBitmap& bitmap); + virtual ~VectorPlatformDeviceEmf(); virtual SkDeviceFactory* getDeviceFactory() { - return SkNEW(VectorPlatformDeviceFactory); + return SkNEW(VectorPlatformDeviceEmfFactory); } virtual HDC getBitmapDC() { @@ -134,12 +135,10 @@ class VectorPlatformDevice : public PlatformDevice { // True if AlphaBlend() was called during this print. bool alpha_blend_used_; - // Copy & assign are not supported. - VectorPlatformDevice(const VectorPlatformDevice&); - const VectorPlatformDevice& operator=(const VectorPlatformDevice&); + DISALLOW_COPY_AND_ASSIGN(VectorPlatformDeviceEmf); }; } // namespace skia -#endif // SKIA_EXT_VECTOR_PLATFORM_DEVICE_WIN_H_ +#endif // SKIA_EXT_VECTOR_PLATFORM_DEVICE_EMF_WIN_H_ diff --git a/skia/skia.gyp b/skia/skia.gyp index 3a058f1..46c34e0 100644 --- a/skia/skia.gyp +++ b/skia/skia.gyp @@ -648,11 +648,10 @@ 'ext/skia_utils_win.h', 'ext/vector_canvas.cc', 'ext/vector_canvas.h', - 'ext/vector_platform_device.h', - 'ext/vector_platform_device_linux.cc', - 'ext/vector_platform_device_linux.h', - 'ext/vector_platform_device_win.cc', - 'ext/vector_platform_device_win.h', + 'ext/vector_platform_device_cairo_linux.cc', + 'ext/vector_platform_device_cairo_linux.h', + 'ext/vector_platform_device_emf_win.cc', + 'ext/vector_platform_device_emf_win.h', ], 'include_dirs': [ '..', diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc index dda0165..b8fd69b 100644 --- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc +++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc @@ -26,7 +26,6 @@ #include "ppapi/c/ppb_instance.h" #include "ppapi/c/ppp_instance.h" #include "printing/units.h" -#include "skia/ext/vector_platform_device.h" #include "skia/ext/platform_canvas.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" @@ -75,6 +74,7 @@ #endif #if defined(OS_WIN) +#include "skia/ext/vector_platform_device_emf_win.h" #include "ui/gfx/codec/jpeg_codec.h" #include "ui/gfx/gdi_util.h" #endif @@ -1231,8 +1231,8 @@ bool PluginInstance::PrintPDFOutput(PP_Resource print_output, #elif defined(OS_WIN) // On Windows, we now need to render the PDF to the DC that backs the // supplied canvas. - skia::VectorPlatformDevice& device = - static_cast<skia::VectorPlatformDevice&>( + skia::VectorPlatformDeviceEmf& device = + static_cast<skia::VectorPlatformDeviceEmf&>( canvas->getTopPlatformDevice()); HDC dc = device.getBitmapDC(); gfx::Size size_in_pixels; @@ -1322,8 +1322,8 @@ bool PluginInstance::DrawJPEGToPlatformDC( const SkBitmap& bitmap, const gfx::Rect& printable_area, WebKit::WebCanvas* canvas) { - skia::VectorPlatformDevice& device = - static_cast<skia::VectorPlatformDevice&>( + skia::VectorPlatformDeviceEmf& device = + static_cast<skia::VectorPlatformDeviceEmf&>( canvas->getTopPlatformDevice()); HDC dc = device.getBitmapDC(); // TODO(sanjeevr): This is a temporary hack. If we output a JPEG |