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

Unified Diff: printing/emf_win.cc

Issue 599733002: StartPage/EndPage from spooling code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tue Sep 23 18:18:33 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/printed_document_win.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 5497495af5d35f238f82482fd43dc603a1f05b6d..f042b2997f73a41fa89447401710c04ceae0520c 100644
--- a/printing/emf_win.cc
+++ b/printing/emf_win.cc
@@ -21,22 +21,6 @@
namespace {
-const int kCustomGdiCommentSignature = 0xdeadbabe;
-struct PageBreakRecord {
- int signature;
- enum PageBreakType {
- START_PAGE,
- END_PAGE,
- } type;
- explicit PageBreakRecord(PageBreakType type_in)
- : signature(kCustomGdiCommentSignature), type(type_in) {
- }
- bool IsValid() const {
- return (signature == kCustomGdiCommentSignature) &&
- (type >= START_PAGE) && (type <= END_PAGE);
- }
-};
-
int CALLBACK IsAlphaBlendUsedEnumProc(HDC,
HANDLETABLE*,
const ENHMETARECORD *record,
@@ -166,7 +150,7 @@ bool DIBFormatNativelySupported(HDC dc, uint32 escape, const BYTE* bits,
return !!supported;
}
-Emf::Emf() : emf_(NULL), hdc_(NULL), page_count_(0) {
+Emf::Emf() : emf_(NULL), hdc_(NULL) {
}
Emf::~Emf() {
@@ -236,8 +220,10 @@ bool Emf::SafePlayback(HDC context) const {
}
Emf::EnumerationContext playback_context;
playback_context.base_matrix = &base_matrix;
- RECT rect = GetPageBounds(1).ToRECT();
- return EnumEnhMetaFile(context,
+ gfx::Rect bound = GetPageBounds(1);
+ RECT rect = bound.ToRECT();
+ return bound.IsEmpty() ||
+ EnumEnhMetaFile(context,
emf_,
&Emf::SafePlaybackProc,
reinterpret_cast<void*>(&playback_context),
@@ -455,34 +441,6 @@ bool Emf::Record::SafePlayback(Emf::EnumerationContext* context) const {
// Ignore it.
res = true;
break;
- case EMR_GDICOMMENT: {
- const EMRGDICOMMENT* comment_record =
- reinterpret_cast<const EMRGDICOMMENT*>(record());
- if (comment_record->cbData == sizeof(PageBreakRecord)) {
- const PageBreakRecord* page_break_record =
- reinterpret_cast<const PageBreakRecord*>(comment_record->Data);
- if (page_break_record && page_break_record->IsValid()) {
- if (page_break_record->type == PageBreakRecord::START_PAGE) {
- res = !!::StartPage(context->hdc);
- DCHECK_EQ(0, context->dc_on_page_start);
- context->dc_on_page_start = ::SaveDC(context->hdc);
- } else if (page_break_record->type == PageBreakRecord::END_PAGE) {
- DCHECK_NE(0, context->dc_on_page_start);
- ::RestoreDC(context->hdc, context->dc_on_page_start);
- context->dc_on_page_start = 0;
- res = !!::EndPage(context->hdc);
- } else {
- res = false;
- NOTREACHED();
- }
- } else {
- res = Play(context);
- }
- } else {
- res = true;
- }
- break;
- }
default: {
res = Play(context);
break;
@@ -505,22 +463,11 @@ SkBaseDevice* Emf::StartPageForVectorCanvas(
bool Emf::StartPage(const gfx::Size& /*page_size*/,
const gfx::Rect& /*content_area*/,
const float& /*scale_factor*/) {
- DCHECK(hdc_);
- if (!hdc_)
- return false;
- page_count_++;
- PageBreakRecord record(PageBreakRecord::START_PAGE);
- return !!GdiComment(hdc_, sizeof(record),
- reinterpret_cast<const BYTE *>(&record));
+ return true;
}
bool Emf::FinishPage() {
- DCHECK(hdc_);
- if (!hdc_)
- return false;
- PageBreakRecord record(PageBreakRecord::END_PAGE);
- return !!GdiComment(hdc_, sizeof(record),
- reinterpret_cast<const BYTE *>(&record));
+ return true;
}
Emf::Enumerator::Enumerator(const Emf& emf, HDC context, const RECT* rect) {
« no previous file with comments | « printing/emf_win.h ('k') | printing/printed_document_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698