diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 518ea05ec071d0..9908de40d6aba0 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -5361,6 +5361,14 @@ Keep your key file in a safe place. You will need it to create new versions of y Reset the last used printer on restart. With this enabled, the OS default printer will become the current printer for print preview on each browser start. + + + Print raster + + + Rasterise page before printing. Slower, but may help to resolve issues with some printers + + CRX-less Web Apps diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc index 51ef078848e1e0..956b8ca4a251bf 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc @@ -223,6 +223,15 @@ const Experiment kExperiments[] = { kOsAll, SINGLE_VALUE_TYPE(switches::kPrintSettingsReset) }, +#if defined(OS_WIN) + { + "print-raster", + IDS_FLAGS_PRINT_RASTER_NAME, + IDS_FLAGS_PRINT_RASTER_DESCRIPTION, + kOsWin, + SINGLE_VALUE_TYPE(switches::kPrintRaster) + }, +#endif // OS_WIN { "crxless-web-apps", IDS_FLAGS_CRXLESS_WEB_APPS_NAME, diff --git a/chrome/browser/printing/print_view_manager.cc b/chrome/browser/printing/print_view_manager.cc index 001f656d15e6e7..abbdc1fe728ee4 100644 --- a/chrome/browser/printing/print_view_manager.cc +++ b/chrome/browser/printing/print_view_manager.cc @@ -7,6 +7,7 @@ #include #include "base/bind.h" +#include "base/command_line.h" #include "base/lazy_instance.h" #include "base/memory/scoped_ptr.h" #include "base/metrics/histogram.h" @@ -24,6 +25,7 @@ #include "chrome/browser/ui/tab_contents/tab_contents.h" #include "chrome/browser/ui/webui/print_preview/print_preview_ui.h" #include "chrome/common/chrome_notification_types.h" +#include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" #include "chrome/common/print_messages.h" #include "content/public/browser/browser_thread.h" @@ -52,6 +54,9 @@ typedef std::map static base::LazyInstance g_scripted_print_preview_closure_map = LAZY_INSTANCE_INITIALIZER; +// Limits memory usage by raster to 64 MiB. +const int kMaxRasterSizeInPixels = 16*1024*1024; + } // namespace namespace printing { @@ -221,18 +226,6 @@ void PrintViewManager::OnDidPrintPage( return; } -#if defined(OS_WIN) - // http://msdn2.microsoft.com/en-us/library/ms535522.aspx - // Windows 2000/XP: When a page in a spooled file exceeds approximately 350 - // MB, it can fail to print and not send an error message. - if (params.data_size && params.data_size >= 350*1024*1024) { - NOTREACHED() << "size:" << params.data_size; - TerminatePrintJob(true); - web_contents()->Stop(); - return; - } -#endif - #if defined(OS_WIN) || defined(OS_MACOSX) const bool metafile_must_be_valid = true; #elif defined(OS_POSIX) @@ -249,7 +242,7 @@ void PrintViewManager::OnDidPrintPage( } } - scoped_ptr metafile(new NativeMetafile); + scoped_ptr metafile(new NativeMetafile); if (metafile_must_be_valid) { if (!metafile->InitFromData(shared_buf.memory(), params.data_size)) { NOTREACHED() << "Invalid metafile header"; @@ -258,6 +251,30 @@ void PrintViewManager::OnDidPrintPage( } } +#if defined(OS_WIN) + bool big_emf = (params.data_size && params.data_size >= kMetafileMaxSize); + const CommandLine* cmdline = CommandLine::ForCurrentProcess(); + if (big_emf || + (cmdline && cmdline->HasSwitch(switches::kPrintRaster)) || + (!print_job_->settings().supports_alpha_blend() && + metafile->IsAlphaBlendUsed())) { + int raster_size = std::min(params.page_size.GetArea(), + kMaxRasterSizeInPixels); + scoped_ptr raster_metafile( + metafile->RasterizeMetafile(raster_size)); + if (raster_metafile.get()) { + metafile.swap(raster_metafile); + } else if (big_emf) { + // Don't fall back to emf here. + NOTREACHED() << "size:" << params.data_size; + TerminatePrintJob(true); + web_contents()->Stop(); + return; + } + } + +#endif + // Update the rendered document. It will send notifications to the listener. document->SetPage(params.page_number, metafile.release(), diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index a069a09d6f1e6c..49e2643401cec5 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -1082,6 +1082,9 @@ const char kPrerenderModeSwitchValueEnabled[] = "enabled"; // prefetch_only: No prerendering, but enables prefetching. const char kPrerenderModeSwitchValuePrefetchOnly[] = "prefetch_only"; +// Enable conversion from vector to raster for any page. +const char kPrintRaster[] = "print-raster"; + // Disable saving the printer and settings between sessions. const char kPrintSettingsReset[] = "print-settings-reset"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index 8fb9953c5e2adb..7d45b2a2b79578 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -437,6 +437,7 @@ extern const char kUseMockKeychain[]; extern const char kDisableDesktopShortcuts[]; extern const char kEnableSyncCredentialCaching[]; extern const char kForceImmersive[]; +extern const char kPrintRaster[]; extern const char kRelaunchShortcut[]; extern const char kWaitForHandle[]; #endif diff --git a/chrome/renderer/print_web_view_helper.h b/chrome/renderer/print_web_view_helper.h index c76bf33cf2e1a6..1180a5dcaa891f 100644 --- a/chrome/renderer/print_web_view_helper.h +++ b/chrome/renderer/print_web_view_helper.h @@ -269,18 +269,14 @@ class PrintWebViewHelper // Platform specific helper function for rendering page(s) to |metafile|. #if defined(OS_WIN) - // Because of mixed support for alpha channels on printers, this method may - // need to create a new metafile. The result may be either the passed - // |metafile| or a new one. In either case, the caller owns both |metafile| - // and the result. - printing::Metafile* RenderPage(const PrintMsg_Print_Params& params, - int page_number, - WebKit::WebFrame* frame, - bool is_preview, - printing::Metafile* metafile, - double* scale_factor, - gfx::Size* page_size_in_dpi, - gfx::Rect* content_area_in_dpi); + void RenderPage(const PrintMsg_Print_Params& params, + int page_number, + WebKit::WebFrame* frame, + bool is_preview, + printing::Metafile* metafile, + double* scale_factor, + gfx::Size* page_size_in_dpi, + gfx::Rect* content_area_in_dpi); #elif defined(OS_MACOSX) void RenderPage(const PrintMsg_Print_Params& params, int page_number, WebKit::WebFrame* frame, bool is_preview, diff --git a/chrome/renderer/print_web_view_helper_win.cc b/chrome/renderer/print_web_view_helper_win.cc index d3e6576b2aa1e7..d827678db44e3c 100644 --- a/chrome/renderer/print_web_view_helper_win.cc +++ b/chrome/renderer/print_web_view_helper_win.cc @@ -32,117 +32,6 @@ using printing::kPointsPerInch; using printing::Metafile; using WebKit::WebFrame; -namespace { - -int CALLBACK EnhMetaFileProc(HDC dc, - HANDLETABLE* handle_table, - const ENHMETARECORD *record, - int num_objects, - LPARAM data) { - HDC* bitmap_dc = reinterpret_cast(data); - // Play this command to the bitmap DC. - PlayEnhMetaFileRecord(*bitmap_dc, handle_table, record, num_objects); - switch (record->iType) { - case EMR_ALPHABLEND: { - const EMRALPHABLEND* emr_alpha_blend = - reinterpret_cast(record); - XFORM bitmap_dc_transform, metafile_dc_transform; - XFORM identity = { 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f }; - // Temporarily set the world transforms of both DC's to identity. - GetWorldTransform(dc, &metafile_dc_transform); - SetWorldTransform(dc, &identity); - GetWorldTransform(*bitmap_dc, &bitmap_dc_transform); - SetWorldTransform(*bitmap_dc, &identity); - const RECTL& rect = emr_alpha_blend->rclBounds; - // Since the printer does not support alpha blend, copy the alpha - // blended region from our (software-rendered) bitmap DC to the - // metafile DC. - BitBlt(dc, - rect.left, - rect.top, - rect.right - rect.left + 1, - rect.bottom - rect.top + 1, - *bitmap_dc, - rect.left, - rect.top, - SRCCOPY); - // Restore the world transforms of both DC's. - SetWorldTransform(dc, &metafile_dc_transform); - SetWorldTransform(*bitmap_dc, &bitmap_dc_transform); - break; - } - - case EMR_CREATEBRUSHINDIRECT: - case EMR_CREATECOLORSPACE: - case EMR_CREATECOLORSPACEW: - case EMR_CREATEDIBPATTERNBRUSHPT: - case EMR_CREATEMONOBRUSH: - case EMR_CREATEPALETTE: - case EMR_CREATEPEN: - case EMR_DELETECOLORSPACE: - case EMR_DELETEOBJECT: - case EMR_EXTCREATEFONTINDIRECTW: - // Play object creation command only once. - break; - - default: - // Play this command to the metafile DC. - PlayEnhMetaFileRecord(dc, handle_table, record, num_objects); - break; - } - return 1; // Continue enumeration -} - -Metafile* FlattenTransparency(Metafile* metafile, const gfx::Size& page_size) { - // Currently, we handle alpha blend transparency for a single page. - // Therefore, expecting a metafile with page count 1. - DCHECK_EQ(1U, metafile->GetPageCount()); - - // Close the device context to retrieve the compiled metafile. - if (!metafile->FinishDocument()) - NOTREACHED(); - - // Page used alpha blend, but printer doesn't support it. Rewrite the - // metafile and flatten out the transparency. - base::win::ScopedGetDC screen_dc(NULL); - base::win::ScopedCreateDC bitmap_dc(CreateCompatibleDC(screen_dc)); - if (!bitmap_dc) - NOTREACHED() << "Bitmap DC creation failed"; - SetGraphicsMode(bitmap_dc, GM_ADVANCED); - void* bits = NULL; - BITMAPINFO hdr; - gfx::CreateBitmapHeader(page_size.width(), page_size.height(), - &hdr.bmiHeader); - base::win::ScopedBitmap hbitmap(CreateDIBSection( - bitmap_dc, &hdr, DIB_RGB_COLORS, &bits, NULL, 0)); - if (!hbitmap) - NOTREACHED() << "Raster bitmap creation for printing failed"; - - base::win::ScopedSelectObject selectBitmap(bitmap_dc, hbitmap); - RECT rect = { 0, 0, page_size.width(), page_size.height() }; - HBRUSH whiteBrush = static_cast(GetStockObject(WHITE_BRUSH)); - FillRect(bitmap_dc, &rect, whiteBrush); - - Metafile* metafile2(new printing::NativeMetafile); - metafile2->Init(); - HDC hdc = metafile2->context(); - DCHECK(hdc); - skia::InitializeDC(hdc); - - RECT metafile_bounds = metafile->GetPageBounds(1).ToRECT(); - // Process the old metafile, placing all non-AlphaBlend calls into the - // new metafile, and copying the results of all the AlphaBlend calls - // from the bitmap DC. - EnumEnhMetaFile(hdc, - metafile->emf(), - EnhMetaFileProc, - &bitmap_dc, - &metafile_bounds); - return metafile2; -} - -} // namespace - void PrintWebViewHelper::PrintPageInternal( const PrintMsg_PrintPage_Params& params, const gfx::Size& canvas_size, @@ -166,9 +55,8 @@ void PrintWebViewHelper::PrintPageInternal( gfx::Rect content_area_in_dpi; // Render page for printing. - metafile.reset(RenderPage(params.params, page_number, frame, false, - metafile.get(), &actual_shrink, &page_size_in_dpi, - &content_area_in_dpi)); + RenderPage(params.params, page_number, frame, false, metafile.get(), + &actual_shrink, &page_size_in_dpi, &content_area_in_dpi); // Close the device context to retrieve the compiled metafile. if (!metafile->FinishDocument()) @@ -210,11 +98,8 @@ bool PrintWebViewHelper::RenderPreviewPage(int page_number) { } base::TimeTicks begin_time = base::TimeTicks::Now(); - printing::Metafile* render_page_result = - RenderPage(print_params, page_number, print_preview_context_.frame(), - true, initial_render_metafile, &actual_shrink, NULL, NULL); - // In the preview flow, RenderPage will never return a new metafile. - DCHECK_EQ(render_page_result, initial_render_metafile); + RenderPage(print_params, page_number, print_preview_context_.frame(), true, + initial_render_metafile, &actual_shrink, NULL, NULL); print_preview_context_.RenderedPreviewPage( base::TimeTicks::Now() - begin_time); @@ -229,7 +114,7 @@ bool PrintWebViewHelper::RenderPreviewPage(int page_number) { return PreviewPageRendered(page_number, draft_metafile.get()); } -Metafile* PrintWebViewHelper::RenderPage( +void PrintWebViewHelper::RenderPage( const PrintMsg_Print_Params& params, int page_number, WebFrame* frame, bool is_preview, Metafile* metafile, double* actual_shrink, gfx::Size* page_size_in_dpi, gfx::Rect* content_area_in_dpi) { @@ -319,27 +204,13 @@ Metafile* PrintWebViewHelper::RenderPage( bool result = metafile->FinishPage(); DCHECK(result); - - if (!params.supports_alpha_blend) { - // PreviewMetafile (PDF) supports alpha blend, so we only hit this case - // for NativeMetafile. - DCHECK(!is_preview); - skia::PlatformDevice* platform_device = skia::GetPlatformDevice(device); - if (platform_device && platform_device->AlphaBlendUsed()) { - return FlattenTransparency(metafile, page_size); - } - } - return metafile; } bool PrintWebViewHelper::CopyMetafileDataToSharedMem( Metafile* metafile, base::SharedMemoryHandle* shared_mem_handle) { uint32 buf_size = metafile->GetDataSize(); base::SharedMemory shared_buf; - // http://msdn2.microsoft.com/en-us/library/ms535522.aspx - // Windows 2000/XP: When a page in a spooled file exceeds approximately 350 - // MB, it can fail to print and not send an error message. - if (buf_size >= 350*1024*1024) { + if (buf_size >= printing::kMetafileMaxSize) { NOTREACHED() << "Buffer too large: " << buf_size; return false; } diff --git a/printing/emf_win.cc b/printing/emf_win.cc index 3634cbddfea74c..a5d4c024070042 100644 --- a/printing/emf_win.cc +++ b/printing/emf_win.cc @@ -7,6 +7,9 @@ #include "base/file_path.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" +#include "base/win/scoped_gdi_object.h" +#include "base/win/scoped_hdc.h" +#include "base/win/scoped_select_object.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" @@ -16,6 +19,7 @@ #include "ui/gfx/size.h" namespace { + const int kCustomGdiCommentSignature = 0xdeadbabe; struct PageBreakRecord { int signature; @@ -31,8 +35,27 @@ struct PageBreakRecord { (type >= START_PAGE) && (type <= END_PAGE); } }; + +int CALLBACK IsAlphaBlendUsedEnumProc(HDC, + HANDLETABLE*, + const ENHMETARECORD *record, + int, + LPARAM data) { + bool* result = reinterpret_cast(data); + if (!result) + return 0; + switch (record->iType) { + case EMR_ALPHABLEND: { + *result = true; + return 0; + break; + } + } + return 1; } +} // namespace + namespace printing { bool DIBFormatNativelySupported(HDC dc, uint32 escape, const BYTE* bits, @@ -126,19 +149,12 @@ gfx::Rect Emf::GetPageBounds(unsigned int page_number) const { NOTREACHED(); return gfx::Rect(); } - if (header.rclBounds.left == 0 && - header.rclBounds.top == 0 && - header.rclBounds.right == -1 && - header.rclBounds.bottom == -1) { - // A freshly created EMF buffer that has no drawing operation has invalid - // bounds. Instead of having an (0,0) size, it has a (-1,-1) size. Detect - // this special case and returns an empty Rect instead of an invalid one. - return gfx::Rect(); - } + // Add 1 to right and bottom because it's inclusive rectangle. + // See ENHMETAHEADER. return gfx::Rect(header.rclBounds.left, header.rclBounds.top, - header.rclBounds.right - header.rclBounds.left, - header.rclBounds.bottom - header.rclBounds.top); + header.rclBounds.right - header.rclBounds.left + 1, + header.rclBounds.bottom - header.rclBounds.top + 1); } uint32 Emf::GetDataSize() const { @@ -478,4 +494,75 @@ int CALLBACK Emf::Enumerator::EnhMetaFileProc(HDC hdc, return 1; } +bool Emf::IsAlphaBlendUsed() const { + bool result = false; + ::EnumEnhMetaFile(NULL, + emf(), + &IsAlphaBlendUsedEnumProc, + &result, + NULL); + return result; +} + +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) { + NOTREACHED() << "Metafile is empty"; + page_bounds = gfx::Rect(1, 1); + } + + float scale = sqrt(float(raster_area_in_pixels) / page_size.GetArea()); + page_size.set_width(std::max(1, page_size.width() * scale)); + page_size.set_height(std::max(1, page_size.height() * scale)); + + base::win::ScopedCreateDC bitmap_dc(::CreateCompatibleDC(NULL)); + if (!bitmap_dc) { + NOTREACHED() << "Bitmap DC creation failed"; + return NULL; + } + ::SetGraphicsMode(bitmap_dc, GM_ADVANCED); + void* bits = NULL; + BITMAPINFO hdr; + gfx::CreateBitmapHeader(page_size.width(), page_size.height(), + &hdr.bmiHeader); + base::win::ScopedBitmap hbitmap(CreateDIBSection( + bitmap_dc, &hdr, DIB_RGB_COLORS, &bits, NULL, 0)); + if (!hbitmap) + NOTREACHED() << "Raster bitmap creation for printing failed"; + + base::win::ScopedSelectObject selectBitmap(bitmap_dc, hbitmap); + RECT rect = { 0, 0, page_size.width(), page_size.height() }; + HBRUSH white_brush = static_cast(::GetStockObject(WHITE_BRUSH)); + FillRect(bitmap_dc, &rect, white_brush); + + gfx::Rect bitmap_rect(page_size); + Playback(bitmap_dc, &bitmap_rect.ToRECT()); + + scoped_ptr result(new Emf); + result->Init(); + HDC hdc = result->context(); + DCHECK(hdc); + skia::InitializeDC(hdc); + + // Params are ignored. + result->StartPage(page_bounds.size(), page_bounds, 1); + + ::ModifyWorldTransform(hdc, NULL, MWT_IDENTITY); + XFORM xform = { + float(page_bounds.width()) / bitmap_rect.width(), 0, + 0, float(page_bounds.height()) / bitmap_rect.height(), + page_bounds.x(), + page_bounds.y(), + }; + ::SetWorldTransform(hdc, &xform); + ::BitBlt(hdc, 0, 0, bitmap_rect.width(), bitmap_rect.height(), + bitmap_dc, bitmap_rect.x(), bitmap_rect.y(), SRCCOPY); + + result->FinishPage(); + result->FinishDocument(); + + return result.release(); +} + } // namespace printing diff --git a/printing/emf_win.h b/printing/emf_win.h index b593e24f357ea5..080025061fe1d6 100644 --- a/printing/emf_win.h +++ b/printing/emf_win.h @@ -23,6 +23,11 @@ class Size; namespace printing { +// http://msdn2.microsoft.com/en-us/library/ms535522.aspx +// Windows 2000/XP: When a page in a spooled file exceeds approximately 350 +// MB, it can fail to print and not send an error message. +const size_t kMetafileMaxSize = 350*1024*1024; + // Simple wrapper class that manage an EMF data stream and its virtual HDC. class PRINTING_EXPORT Emf : public Metafile { public: @@ -86,6 +91,13 @@ class PRINTING_EXPORT Emf : public Metafile { return emf_; } + // Returns true if metafile contains alpha blend. + bool IsAlphaBlendUsed() const; + + // Returns new metafile with only bitmap created by playback of the current + // metafile. Returns NULL if fails. + Emf* RasterizeMetafile(int raster_area_in_pixels) const; + private: FRIEND_TEST_ALL_PREFIXES(EmfTest, DC); FRIEND_TEST_ALL_PREFIXES(EmfPrintingTest, PageBreak); diff --git a/printing/emf_win_unittest.cc b/printing/emf_win_unittest.cc index 8d072132285066..ac30fd0c4b5925 100644 --- a/printing/emf_win_unittest.cc +++ b/printing/emf_win_unittest.cc @@ -202,4 +202,29 @@ TEST(EmfTest, FileBackedEmf) { EXPECT_TRUE(DeleteDC(hdc)); } +TEST(EmfTest, RasterizeMetafile) { + Emf emf; + EXPECT_TRUE(emf.Init()); + EXPECT_TRUE(emf.context() != NULL); + HBRUSH brush = static_cast(GetStockObject(BLACK_BRUSH)); + for (int i = 0; i < 4; ++i) { + RECT rect = { 5 + i, 5 + i, 5 + i + 1, 5 + i + 2}; + FillRect(emf.context(), &rect, brush); + } + EXPECT_TRUE(emf.FinishDocument()); + + scoped_ptr raster(emf.RasterizeMetafile(1)); + // Just 1px bitmap but should be stretched to the same bounds. + EXPECT_EQ(emf.GetPageBounds(1), raster->GetPageBounds(1)); + + raster.reset(emf.RasterizeMetafile(20)); + EXPECT_EQ(emf.GetPageBounds(1), raster->GetPageBounds(1)); + + raster.reset(emf.RasterizeMetafile(16*1024*1024)); + // Expected size about 64MB. + EXPECT_LE(abs(int(raster->GetDataSize()) - 64*1024*1024), 1024*1024); + // Bounds should still be the same. + EXPECT_EQ(emf.GetPageBounds(1), raster->GetPageBounds(1)); +} + } // namespace printing diff --git a/skia/ext/platform_device.cc b/skia/ext/platform_device.cc index 6292273a8b5116..f280aaf8728bed 100644 --- a/skia/ext/platform_device.cc +++ b/skia/ext/platform_device.cc @@ -76,8 +76,4 @@ bool PlatformDevice::IsNativeFontRenderingAllowed() { return true; } -bool PlatformDevice::AlphaBlendUsed() const { - return false; -} - } // namespace skia diff --git a/skia/ext/platform_device.h b/skia/ext/platform_device.h index 627cd3253d72dd..3263902941ba90 100644 --- a/skia/ext/platform_device.h +++ b/skia/ext/platform_device.h @@ -124,11 +124,6 @@ class SK_API PlatformDevice { // Returns if GDI is allowed to render text to this device. virtual bool IsNativeFontRenderingAllowed(); - // True if AlphaBlend() was called during a - // BeginPlatformPaint()/EndPlatformPaint() pair. - // Used by the printing subclasses. See |VectorPlatformDeviceEmf|. - virtual bool AlphaBlendUsed() const; - #if defined(OS_WIN) // Loads a SkPath into the GDI context. The path can there after be used for // clipping or as a stroke. Returns false if the path failed to be loaded. diff --git a/skia/ext/vector_platform_device_emf_win.cc b/skia/ext/vector_platform_device_emf_win.cc index 3c34800fa790e7..73be49119fd1b2 100644 --- a/skia/ext/vector_platform_device_emf_win.cc +++ b/skia/ext/vector_platform_device_emf_win.cc @@ -100,8 +100,7 @@ VectorPlatformDeviceEmf::VectorPlatformDeviceEmf(HDC dc, const SkBitmap& bitmap) : SkDevice(bitmap), hdc_(dc), previous_brush_(NULL), - previous_pen_(NULL), - alpha_blend_used_(false) { + previous_pen_(NULL) { transform_.reset(); SetPlatformDevice(this, this); } @@ -854,8 +853,6 @@ void VectorPlatformDeviceEmf::InternalDrawBitmap(const SkBitmap& bitmap, result = SetStretchBltMode(dc, previous_mode); SkASSERT(result); - alpha_blend_used_ = true; - ::SelectObject(bitmap_dc, static_cast(old_bitmap)); DeleteObject(hbitmap); DeleteDC(bitmap_dc); diff --git a/skia/ext/vector_platform_device_emf_win.h b/skia/ext/vector_platform_device_emf_win.h index fc6c61c21fafba..6d84d3a8be481d 100644 --- a/skia/ext/vector_platform_device_emf_win.h +++ b/skia/ext/vector_platform_device_emf_win.h @@ -32,8 +32,6 @@ class VectorPlatformDeviceEmf : public SkDevice, public PlatformDevice { virtual PlatformSurface BeginPlatformPaint() OVERRIDE; virtual void DrawToNativeContext(HDC dc, int x, int y, const RECT* src_rect) OVERRIDE; - virtual bool AlphaBlendUsed() const OVERRIDE { return alpha_blend_used_; } - // SkDevice methods. virtual uint32_t getDeviceCapabilities(); virtual void drawPaint(const SkDraw& draw, const SkPaint& paint) OVERRIDE; @@ -126,9 +124,6 @@ class VectorPlatformDeviceEmf : public SkDevice, public PlatformDevice { // Previously selected pen before the current drawing. HGDIOBJ previous_pen_; - // True if AlphaBlend() was called during this print. - bool alpha_blend_used_; - DISALLOW_COPY_AND_ASSIGN(VectorPlatformDeviceEmf); };