Index: skia/ext/vector_device.cc |
=================================================================== |
--- skia/ext/vector_device.cc (revision 7318) |
+++ skia/ext/vector_device.cc (working copy) |
@@ -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() { |
- DCHECK(previous_brush_ == NULL); |
- DCHECK(previous_pen_ == NULL); |
+ SkASSERT(previous_brush_ == NULL); |
+ SkASSERT(previous_pen_ == NULL); |
} |
@@ -77,7 +75,7 @@ |
return; |
if (mode == SkCanvas::kPoints_PointMode) { |
- NOTREACHED(); |
+ SkASSERT(false); |
return; |
} |
@@ -89,7 +87,7 @@ |
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 @@ |
} |
break; |
default: |
- NOTREACHED(); |
+ SkASSERT(false); |
return; |
} |
// Draw the calculated path. |
@@ -139,7 +137,7 @@ |
SkScalarRound(rect.fTop), |
SkScalarRound(rect.fRight), |
SkScalarRound(rect.fBottom))) { |
- NOTREACHED(); |
+ SkASSERT(false); |
} |
Cleanup(); |
} |
@@ -168,21 +166,21 @@ |
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::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 @@ |
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 @@ |
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 @@ |
// 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::drawToHDC(HDC dc, int x, int y, const RECT* src_rect) { |
- NOTREACHED(); |
+ SkASSERT(false); |
} |
void VectorDevice::LoadClipRegion() { |
@@ -351,7 +349,7 @@ |
} |
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 @@ |
if (!use_brush) { |
// Set the transparency. |
if (0 == SetBkMode(hdc_, TRANSPARENT)) { |
- NOTREACHED(); |
+ SkASSERT(false); |
return false; |
} |
@@ -370,7 +368,7 @@ |
// Set the opacity. |
if (0 == SetBkMode(hdc_, OPAQUE)) { |
- NOTREACHED(); |
+ SkASSERT(false); |
return false; |
} |
@@ -381,7 +379,7 @@ |
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 @@ |
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 @@ |
previous_brush_ = NULL; |
if (result) { |
BOOL res = DeleteObject(result); |
- DCHECK(res != 0); |
+ SkASSERT(res != 0); |
} |
} |
if (previous_pen_) { |
@@ -431,7 +429,7 @@ |
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 @@ |
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 @@ |
// 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 @@ |
// 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 @@ |
pen_style |= PS_JOIN_BEVEL; |
break; |
default: |
- NOTREACHED(); |
+ SkASSERT(false); |
break; |
} |
switch (paint.getStrokeCap()) { |
@@ -497,7 +495,7 @@ |
pen_style |= PS_ENDCAP_SQUARE; |
break; |
default: |
- NOTREACHED(); |
+ SkASSERT(false); |
break; |
} |
@@ -510,7 +508,7 @@ |
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 @@ |
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 @@ |
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 @@ |
// 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 @@ |
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 @@ |
reinterpret_cast<const BITMAPINFO*>(&hdr), |
DIB_RGB_COLORS, |
SRCCOPY); |
- DCHECK(result); |
+ SkASSERT(result); |
} |
Cleanup(); |
} |