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

Unified Diff: printing/pdf_ps_metafile_cairo.cc

Issue 2807027: Added support for vector printing for Pepper v1 plugins for Linux.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Merged Created 10 years, 6 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/pdf_ps_metafile_cairo.h ('k') | printing/pdf_ps_metafile_cairo_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: printing/pdf_ps_metafile_cairo.cc
===================================================================
--- printing/pdf_ps_metafile_cairo.cc (revision 51151)
+++ printing/pdf_ps_metafile_cairo.cc (working copy)
@@ -19,6 +19,8 @@
namespace {
+const cairo_user_data_key_t kPdfMetafileKey = {0};
+
// Tests if |surface| is valid.
bool IsSurfaceValid(cairo_surface_t* surface) {
return cairo_surface_status(surface) == CAIRO_STATUS_SUCCESS;
@@ -60,6 +62,10 @@
return CAIRO_STATUS_SUCCESS;
}
+void DestroyContextData(void* data) {
+ // Nothing to be done here.
+}
+
} // namespace
namespace printing {
@@ -115,6 +121,8 @@
return false;
}
+ cairo_set_user_data(context_, &kPdfMetafileKey, this, DestroyContextData);
+
return true;
}
@@ -133,6 +141,23 @@
return true;
}
+bool PdfPsMetafile::SetRawData(const void* src_buffer,
+ uint32 src_buffer_size) {
+ if (!context_) {
+ // If Init has not already been called, just call Init()
+ return Init(src_buffer, src_buffer_size);
+ }
+ // If a context has already been created, remember this data in
+ // raw_override_data_
+ if (src_buffer == NULL || src_buffer_size == 0)
+ return false;
+
+ raw_override_data_ = std::string(reinterpret_cast<const char*>(src_buffer),
+ src_buffer_size);
+
+ return true;
+}
+
cairo_t* PdfPsMetafile::StartPage(double width_in_points,
double height_in_points,
double margin_top_in_points,
@@ -191,6 +216,12 @@
DCHECK(IsContextValid(context_));
cairo_surface_finish(surface_);
+
+ // If we have raw PDF/PS data set use that instead of what was drawn.
+ if (!raw_override_data_.empty()) {
+ data_ = raw_override_data_;
+ raw_override_data_.clear();
+ }
DCHECK(!data_.empty()); // Make sure we did get something.
CleanUpContext(&context_);
@@ -242,6 +273,11 @@
return success;
}
+PdfPsMetafile* PdfPsMetafile::FromCairoContext(cairo_t* context) {
+ return reinterpret_cast<PdfPsMetafile*>(
+ cairo_get_user_data(context, &kPdfMetafileKey));
+}
+
void PdfPsMetafile::CleanUpAll() {
CleanUpContext(&context_);
CleanUpSurface(&surface_);
« no previous file with comments | « printing/pdf_ps_metafile_cairo.h ('k') | printing/pdf_ps_metafile_cairo_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698