summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-26 04:09:10 +0000
committervitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-26 04:09:10 +0000
commit47d1474d116ffe95eb6d54bdce6b1c5f3e8fecc8 (patch)
tree25167120498902f2346848f012236390623f952b
parenta46d2ac3459fffd531e0857a22384db179405953 (diff)
downloadchromium_src-47d1474d116ffe95eb6d54bdce6b1c5f3e8fecc8.zip
chromium_src-47d1474d116ffe95eb6d54bdce6b1c5f3e8fecc8.tar.gz
chromium_src-47d1474d116ffe95eb6d54bdce6b1c5f3e8fecc8.tar.bz2
Fixed code disabled by invalide DCHECK use.
Other minor cleanup. BUG=172198 Review URL: https://chromiumcodereview.appspot.com/12038105 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@179020 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--printing/image_win.cc22
1 files changed, 11 insertions, 11 deletions
diff --git a/printing/image_win.cc b/printing/image_win.cc
index de731e0..fdf99c8 100644
--- a/printing/image_win.cc
+++ b/printing/image_win.cc
@@ -4,11 +4,15 @@
#include "printing/image.h"
+#include "base/win/scoped_gdi_object.h"
+#include "base/win/scoped_hdc.h"
+#include "base/win/scoped_select_object.h"
#include "printing/metafile.h"
#include "skia/ext/platform_device.h"
#include "ui/gfx/gdi_util.h" // EMF support
#include "ui/gfx/rect.h"
+
namespace {
// A simple class which temporarily overrides system settings.
@@ -50,7 +54,7 @@ bool Image::LoadMetafile(const Metafile& metafile) {
DisableFontSmoothing disable_in_this_scope;
// Create a temporary HDC and bitmap to retrieve the rendered data.
- HDC hdc = CreateCompatibleDC(NULL);
+ base::win::ScopedCreateDC hdc(::CreateCompatibleDC(NULL));
BITMAPV4HEADER hdr;
DCHECK_EQ(rect.x(), 0);
DCHECK_EQ(rect.y(), 0);
@@ -62,12 +66,12 @@ bool Image::LoadMetafile(const Metafile& metafile) {
size_ = rect.size();
gfx::CreateBitmapV4Header(rect.width(), rect.height(), &hdr);
- void* bits;
- HBITMAP bitmap = CreateDIBSection(hdc,
- reinterpret_cast<BITMAPINFO*>(&hdr), 0,
- &bits, NULL, 0);
+ unsigned char* bits = NULL;
+ base::win::ScopedBitmap bitmap(
+ ::CreateDIBSection(hdc, reinterpret_cast<BITMAPINFO*>(&hdr), 0,
+ reinterpret_cast<void**>(&bits), NULL, 0));
DCHECK(bitmap);
- DCHECK(SelectObject(hdc, bitmap));
+ base::win::ScopedSelectObject select_object(hdc, bitmap);
skia::InitializeDC(hdc);
@@ -77,11 +81,7 @@ bool Image::LoadMetafile(const Metafile& metafile) {
size_t bytes = row_length_ * size_.height();
DCHECK(bytes);
- data_.resize(bytes);
- memcpy(&*data_.begin(), bits, bytes);
-
- DeleteDC(hdc);
- DeleteObject(bitmap);
+ data_.assign(bits, bits + bytes);
return success;
}