diff options
author | brettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-19 21:18:21 +0000 |
---|---|---|
committer | brettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-19 21:18:21 +0000 |
commit | 0026e48d1cf39bac65875fba6f5d38eb550a22f9 (patch) | |
tree | b144d2619f68e667f8970c91b72cd2478b9231c3 /skia/ext/vector_device.cc | |
parent | 28461252ccd08f81ba91e89428fce03f9d66530a (diff) | |
download | chromium_src-0026e48d1cf39bac65875fba6f5d38eb550a22f9.zip chromium_src-0026e48d1cf39bac65875fba6f5d38eb550a22f9.tar.gz chromium_src-0026e48d1cf39bac65875fba6f5d38eb550a22f9.tar.bz2 |
Remove base dependencies in the Windows-specific skia/ext code.
Review URL: http://codereview.chromium.org/14900
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7317 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia/ext/vector_device.cc')
-rw-r--r-- | skia/ext/vector_device.cc | 101 |
1 files changed, 51 insertions, 50 deletions
diff --git a/skia/ext/vector_device.cc b/skia/ext/vector_device.cc index 98aaeff..295101f 100644 --- a/skia/ext/vector_device.cc +++ b/skia/ext/vector_device.cc @@ -5,8 +5,6 @@ #include "skia/ext/vector_device.h" #include "base/gfx/gdi_util.h" -#include "base/logging.h" -#include "base/scoped_handle.h" #include "skia/ext/skia_utils_win.h" #include "SkUtils.h" @@ -55,8 +53,8 @@ VectorDevice::VectorDevice(HDC dc, const SkBitmap& bitmap) } VectorDevice::~VectorDevice() { - DCHECK(previous_brush_ == NULL); - DCHECK(previous_pen_ == NULL); + SkASSERT(previous_brush_ == NULL); + SkASSERT(previous_pen_ == NULL); } @@ -77,7 +75,7 @@ void VectorDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, return; if (mode == SkCanvas::kPoints_PointMode) { - NOTREACHED(); + SkASSERT(false); return; } @@ -89,7 +87,7 @@ void VectorDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, switch (mode) { case SkCanvas::kLines_PointMode: if (count % 2) { - NOTREACHED(); + SkASSERT(false); return; } for (size_t i = 0; i < count / 2; ++i) { @@ -104,7 +102,7 @@ void VectorDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, } break; default: - NOTREACHED(); + SkASSERT(false); return; } // Draw the calculated path. @@ -139,7 +137,7 @@ void VectorDevice::drawRect(const SkDraw& draw, const SkRect& rect, SkScalarRound(rect.fTop), SkScalarRound(rect.fRight), SkScalarRound(rect.fBottom))) { - NOTREACHED(); + SkASSERT(false); } Cleanup(); } @@ -168,21 +166,21 @@ void VectorDevice::drawPath(const SkDraw& draw, const SkPath& path, switch (paint.getStyle()) { case SkPaint::kFill_Style: { BOOL res = StrokeAndFillPath(dc); - DCHECK(res != 0); + SkASSERT(res != 0); break; } case SkPaint::kStroke_Style: { BOOL res = StrokePath(dc); - DCHECK(res != 0); + SkASSERT(res != 0); break; } case SkPaint::kStrokeAndFill_Style: { BOOL res = StrokeAndFillPath(dc); - DCHECK(res != 0); + SkASSERT(res != 0); break; } default: - NOTREACHED(); + SkASSERT(false); break; } Cleanup(); @@ -217,14 +215,14 @@ void VectorDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap, void VectorDevice::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. - NOTREACHED(); + SkASSERT(false); } void VectorDevice::drawPosText(const SkDraw& draw, const void* text, size_t len, const SkScalar pos[], SkScalar constY, int scalarsPerPos, const SkPaint& paint) { // This function isn't used in the code. Verify this assumption. - NOTREACHED(); + SkASSERT(false); } void VectorDevice::drawTextOnPath(const SkDraw& draw, const void* text, @@ -232,7 +230,7 @@ void VectorDevice::drawTextOnPath(const SkDraw& draw, const void* text, const SkPath& path, const SkMatrix* matrix, const SkPaint& paint) { // This function isn't used in the code. Verify this assumption. - NOTREACHED(); + SkASSERT(false); } void VectorDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode, @@ -242,7 +240,7 @@ void VectorDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode, const uint16_t indices[], int indexCount, const SkPaint& paint) { // This function isn't used in the code. Verify this assumption. - NOTREACHED(); + SkASSERT(false); } void VectorDevice::drawDevice(const SkDraw& draw, SkDevice* device, int x, @@ -309,25 +307,25 @@ bool VectorDevice::ApplyPaint(const SkPaint& paint) { // SkShader::CreateBitmapShader // SkGradientShader::CreateRadial // SkGradientShader::CreateLinear - // DCHECK(!paint.getShader()); + // SkASSERT(!paint.getShader()); // http://b/1106647 Implement loopers and mask filter. Looper currently in // use: // SkBlurDrawLooper is used for shadows. - // DCHECK(!paint.getLooper()); - // DCHECK(!paint.getMaskFilter()); + // SkASSERT(!paint.getLooper()); + // SkASSERT(!paint.getMaskFilter()); // http://b/1165900 Implement xfermode. - // DCHECK(!paint.getXfermode()); + // SkASSERT(!paint.getXfermode()); // The path effect should be processed before arriving here. - DCHECK(!paint.getPathEffect()); + SkASSERT(!paint.getPathEffect()); // These aren't used in the code. Verify this assumption. - DCHECK(!paint.getColorFilter()); - DCHECK(!paint.getRasterizer()); + SkASSERT(!paint.getColorFilter()); + SkASSERT(!paint.getRasterizer()); // Reuse code to load Win32 Fonts. - DCHECK(!paint.getTypeface()); + SkASSERT(!paint.getTypeface()); return true; } @@ -341,7 +339,7 @@ void VectorDevice::setMatrixClip(const SkMatrix& transform, } void VectorDevice::drawToHDC(HDC dc, int x, int y, const RECT* src_rect) { - NOTREACHED(); + SkASSERT(false); } void VectorDevice::LoadClipRegion() { @@ -351,7 +349,7 @@ void VectorDevice::LoadClipRegion() { } bool VectorDevice::CreateBrush(bool use_brush, COLORREF color) { - DCHECK(previous_brush_ == NULL); + 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 // WHITE_BRUSH instead. @@ -359,7 +357,7 @@ bool VectorDevice::CreateBrush(bool use_brush, COLORREF color) { if (!use_brush) { // Set the transparency. if (0 == SetBkMode(hdc_, TRANSPARENT)) { - NOTREACHED(); + SkASSERT(false); return false; } @@ -370,7 +368,7 @@ bool VectorDevice::CreateBrush(bool use_brush, COLORREF color) { // Set the opacity. if (0 == SetBkMode(hdc_, OPAQUE)) { - NOTREACHED(); + SkASSERT(false); return false; } @@ -381,7 +379,7 @@ bool VectorDevice::CreateBrush(bool use_brush, COLORREF color) { bool VectorDevice::CreatePen(bool use_pen, COLORREF color, int stroke_width, float stroke_miter, DWORD pen_style) { - DCHECK(previous_pen_ == NULL); + 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 // instead. @@ -405,13 +403,13 @@ bool VectorDevice::CreatePen(bool use_pen, COLORREF color, int stroke_width, brush.lbColor = color; brush.lbHatch = 0; HPEN pen = ExtCreatePen(pen_style, stroke_width, &brush, 0, NULL); - DCHECK(pen != NULL); + SkASSERT(pen != NULL); previous_pen_ = SelectObject(pen); if (previous_pen_ == NULL) return false; if (!SetMiterLimit(hdc_, stroke_miter, NULL)) { - NOTREACHED(); + SkASSERT(false); return false; } return true; @@ -423,7 +421,7 @@ void VectorDevice::Cleanup() { previous_brush_ = NULL; if (result) { BOOL res = DeleteObject(result); - DCHECK(res != 0); + SkASSERT(res != 0); } } if (previous_pen_) { @@ -431,7 +429,7 @@ void VectorDevice::Cleanup() { previous_pen_ = NULL; if (result) { BOOL res = DeleteObject(result); - DCHECK(res != 0); + SkASSERT(res != 0); } } // Remove any loaded path from the context. @@ -440,7 +438,7 @@ void VectorDevice::Cleanup() { HGDIOBJ VectorDevice::SelectObject(HGDIOBJ object) { HGDIOBJ result = ::SelectObject(hdc_, object); - DCHECK(result != HGDI_ERROR); + SkASSERT(result != HGDI_ERROR); if (result == HGDI_ERROR) return NULL; return result; @@ -450,7 +448,7 @@ bool VectorDevice::CreateBrush(bool use_brush, const SkPaint& paint) { // Make sure that for transparent color, no brush is used. if (paint.getAlpha() == 0) { // Test if it ever happen. - NOTREACHED(); + SkASSERT(false); use_brush = false; } @@ -461,7 +459,7 @@ bool VectorDevice::CreatePen(bool use_pen, const SkPaint& paint) { // Make sure that for transparent color, no pen is used. if (paint.getAlpha() == 0) { // Test if it ever happen. - NOTREACHED(); + SkASSERT(false); use_pen = false; } @@ -480,7 +478,7 @@ bool VectorDevice::CreatePen(bool use_pen, const SkPaint& paint) { pen_style |= PS_JOIN_BEVEL; break; default: - NOTREACHED(); + SkASSERT(false); break; } switch (paint.getStrokeCap()) { @@ -497,7 +495,7 @@ bool VectorDevice::CreatePen(bool use_pen, const SkPaint& paint) { pen_style |= PS_ENDCAP_SQUARE; break; default: - NOTREACHED(); + SkASSERT(false); break; } @@ -510,7 +508,7 @@ bool VectorDevice::CreatePen(bool use_pen, const SkPaint& paint) { void VectorDevice::InternalDrawBitmap(const SkBitmap& bitmap, int x, int y, const SkPaint& paint) { - uint8 alpha = paint.getAlpha(); + unsigned char alpha = paint.getAlpha(); if (alpha == 0) return; @@ -537,10 +535,10 @@ void VectorDevice::InternalDrawBitmap(const SkBitmap& bitmap, int x, int y, gfx::CreateBitmapV4Header(src_size_x, src_size_y, &bitmap_header); HDC dc = getBitmapDC(); SkAutoLockPixels lock(bitmap); - DCHECK_EQ(bitmap.getConfig(), SkBitmap::kARGB_8888_Config); + SkASSERT(bitmap.getConfig() == SkBitmap::kARGB_8888_Config); const uint32_t* pixels = static_cast<const uint32_t*>(bitmap.getPixels()); if (pixels == NULL) { - NOTREACHED(); + SkASSERT(false); return; } @@ -562,15 +560,14 @@ void VectorDevice::InternalDrawBitmap(const SkBitmap& bitmap, int x, int y, gfx::CreateBitmapHeader(src_size_x, src_size_y, &hdr); if (is_translucent) { // The image must be loaded as a bitmap inside a device context. - ScopedHDC bitmap_dc(::CreateCompatibleDC(dc)); + HDC bitmap_dc = ::CreateCompatibleDC(dc); void* bits = NULL; - ScopedBitmap hbitmap(::CreateDIBSection( + HBITMAP hbitmap = ::CreateDIBSection( bitmap_dc, reinterpret_cast<const BITMAPINFO*>(&hdr), - DIB_RGB_COLORS, &bits, NULL, 0)); + DIB_RGB_COLORS, &bits, NULL, 0); memcpy(bits, pixels, bitmap.getSize()); - DCHECK(hbitmap); + SkASSERT(hbitmap); HGDIOBJ old_bitmap = ::SelectObject(bitmap_dc, hbitmap); - DeleteObject(old_bitmap); // After some analysis of IE7's behavior, this is the thing to do. I was // sure IE7 was doing so kind of bitmasking due to the way translucent image @@ -580,7 +577,7 @@ void VectorDevice::InternalDrawBitmap(const SkBitmap& bitmap, int x, int y, // what the driver expects. DWORD previous_mode = GetStretchBltMode(dc); BOOL result = SetStretchBltMode(dc, COLORONCOLOR); - DCHECK(result); + SkASSERT(result); // Note that this function expect premultiplied colors (!) BLENDFUNCTION blend_function = {AC_SRC_OVER, 0, alpha, AC_SRC_ALPHA}; result = GdiAlphaBlend(dc, @@ -590,9 +587,13 @@ void VectorDevice::InternalDrawBitmap(const SkBitmap& bitmap, int x, int y, 0, 0, // Source origin. src_size_x, src_size_y, // Source size. blend_function); - DCHECK(result); + SkASSERT(result); result = SetStretchBltMode(dc, previous_mode); - DCHECK(result); + SkASSERT(result); + + ::SelectObject(bitmap_dc, static_cast<HBITMAP>(old_bitmap)); + DeleteObject(hbitmap); + DeleteDC(bitmap_dc); } else { BOOL result = StretchDIBits(dc, x, y, // Destination origin. @@ -603,7 +604,7 @@ void VectorDevice::InternalDrawBitmap(const SkBitmap& bitmap, int x, int y, reinterpret_cast<const BITMAPINFO*>(&hdr), DIB_RGB_COLORS, SRCCOPY); - DCHECK(result); + SkASSERT(result); } Cleanup(); } |