| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2003, 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2003, 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 | 137 |
| 138 GraphicsContext::~GraphicsContext() | 138 GraphicsContext::~GraphicsContext() |
| 139 { | 139 { |
| 140 ASSERT(!m_paintStateIndex); | 140 ASSERT(!m_paintStateIndex); |
| 141 ASSERT(!m_paintState->m_saveCount); | 141 ASSERT(!m_paintState->m_saveCount); |
| 142 ASSERT(!m_annotationCount); | 142 ASSERT(!m_annotationCount); |
| 143 ASSERT(!m_layerCount); | 143 ASSERT(!m_layerCount); |
| 144 ASSERT(m_recordingStateStack.isEmpty()); | 144 ASSERT(m_recordingStateStack.isEmpty()); |
| 145 } | 145 } |
| 146 | 146 |
| 147 const SkBitmap* GraphicsContext::bitmap() const | |
| 148 { | |
| 149 TRACE_EVENT0("skia", "GraphicsContext::bitmap"); | |
| 150 return &m_canvas->getDevice()->accessBitmap(false); | |
| 151 } | |
| 152 | |
| 153 const SkBitmap& GraphicsContext::layerBitmap(AccessMode access) const | |
| 154 { | |
| 155 return m_canvas->getTopDevice()->accessBitmap(access == ReadWrite); | |
| 156 } | |
| 157 | |
| 158 void GraphicsContext::save() | 147 void GraphicsContext::save() |
| 159 { | 148 { |
| 160 if (paintingDisabled()) | 149 if (paintingDisabled()) |
| 161 return; | 150 return; |
| 162 | 151 |
| 163 m_paintState->m_saveCount++; | 152 m_paintState->m_saveCount++; |
| 164 | 153 |
| 165 m_canvasStateStack.append(CanvasSaveState(m_canvasSaveFlags, m_canvas->getSa
veCount())); | 154 m_canvasStateStack.append(CanvasSaveState(m_canvasSaveFlags, m_canvas->getSa
veCount())); |
| 166 m_canvasSaveFlags |= SkCanvas::kMatrixClip_SaveFlag; | 155 m_canvasSaveFlags |= SkCanvas::kMatrixClip_SaveFlag; |
| 167 } | 156 } |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 } | 341 } |
| 353 | 342 |
| 354 void GraphicsContext::clearDrawLooper() | 343 void GraphicsContext::clearDrawLooper() |
| 355 { | 344 { |
| 356 if (paintingDisabled()) | 345 if (paintingDisabled()) |
| 357 return; | 346 return; |
| 358 | 347 |
| 359 mutableState()->m_looper.clear(); | 348 mutableState()->m_looper.clear(); |
| 360 } | 349 } |
| 361 | 350 |
| 362 bool GraphicsContext::hasShadow() const | |
| 363 { | |
| 364 return !!immutableState()->m_looper; | |
| 365 } | |
| 366 | |
| 367 int GraphicsContext::getNormalizedAlpha() const | 351 int GraphicsContext::getNormalizedAlpha() const |
| 368 { | 352 { |
| 369 int alpha = roundf(immutableState()->m_alpha * 256); | 353 int alpha = roundf(immutableState()->m_alpha * 256); |
| 370 if (alpha > 255) | 354 if (alpha > 255) |
| 371 alpha = 255; | 355 alpha = 255; |
| 372 else if (alpha < 0) | 356 else if (alpha < 0) |
| 373 alpha = 0; | 357 alpha = 0; |
| 374 return alpha; | 358 return alpha; |
| 375 } | 359 } |
| 376 | 360 |
| (...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1106 drawImage(image, FloatRect(IntRect(p, image->size())), FloatRect(FloatPoint(
), FloatSize(image->size())), op, shouldRespectImageOrientation); | 1090 drawImage(image, FloatRect(IntRect(p, image->size())), FloatRect(FloatPoint(
), FloatSize(image->size())), op, shouldRespectImageOrientation); |
| 1107 } | 1091 } |
| 1108 | 1092 |
| 1109 void GraphicsContext::drawImage(Image* image, const IntRect& r, CompositeOperato
r op, RespectImageOrientationEnum shouldRespectImageOrientation, bool useLowQual
ityScale) | 1093 void GraphicsContext::drawImage(Image* image, const IntRect& r, CompositeOperato
r op, RespectImageOrientationEnum shouldRespectImageOrientation, bool useLowQual
ityScale) |
| 1110 { | 1094 { |
| 1111 if (!image) | 1095 if (!image) |
| 1112 return; | 1096 return; |
| 1113 drawImage(image, FloatRect(r), FloatRect(FloatPoint(), FloatSize(image->size
())), op, shouldRespectImageOrientation, useLowQualityScale); | 1097 drawImage(image, FloatRect(r), FloatRect(FloatPoint(), FloatSize(image->size
())), op, shouldRespectImageOrientation, useLowQualityScale); |
| 1114 } | 1098 } |
| 1115 | 1099 |
| 1116 void GraphicsContext::drawImage(Image* image, const IntPoint& dest, const IntRec
t& srcRect, CompositeOperator op, RespectImageOrientationEnum shouldRespectImage
Orientation) | |
| 1117 { | |
| 1118 drawImage(image, FloatRect(IntRect(dest, srcRect.size())), FloatRect(srcRect
), op, shouldRespectImageOrientation); | |
| 1119 } | |
| 1120 | |
| 1121 void GraphicsContext::drawImage(Image* image, const FloatRect& dest, const Float
Rect& src, CompositeOperator op, RespectImageOrientationEnum shouldRespectImageO
rientation, bool useLowQualityScale) | 1100 void GraphicsContext::drawImage(Image* image, const FloatRect& dest, const Float
Rect& src, CompositeOperator op, RespectImageOrientationEnum shouldRespectImageO
rientation, bool useLowQualityScale) |
| 1122 { | 1101 { |
| 1123 drawImage(image, dest, src, op, blink::WebBlendModeNormal, shouldRespectImag
eOrientation, useLowQualityScale); | 1102 drawImage(image, dest, src, op, blink::WebBlendModeNormal, shouldRespectImag
eOrientation, useLowQualityScale); |
| 1124 } | 1103 } |
| 1125 | 1104 |
| 1126 void GraphicsContext::drawImage(Image* image, const FloatRect& dest) | 1105 void GraphicsContext::drawImage(Image* image, const FloatRect& dest) |
| 1127 { | 1106 { |
| 1128 if (!image) | 1107 if (!image) |
| 1129 return; | 1108 return; |
| 1130 drawImage(image, dest, FloatRect(IntRect(IntPoint(), image->size()))); | 1109 drawImage(image, dest, FloatRect(IntRect(IntPoint(), image->size()))); |
| (...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1782 OwnPtr<ImageBufferSurface> surface = adoptPtr(new CompatibleImageBufferSurfa
ce(device.release(), scaledSize, opacityMode)); | 1761 OwnPtr<ImageBufferSurface> surface = adoptPtr(new CompatibleImageBufferSurfa
ce(device.release(), scaledSize, opacityMode)); |
| 1783 ASSERT(surface->isValid()); | 1762 ASSERT(surface->isValid()); |
| 1784 OwnPtr<ImageBuffer> buffer = adoptPtr(new ImageBuffer(surface.release())); | 1763 OwnPtr<ImageBuffer> buffer = adoptPtr(new ImageBuffer(surface.release())); |
| 1785 | 1764 |
| 1786 buffer->context()->scale(FloatSize(static_cast<float>(scaledSize.width()) /
size.width(), | 1765 buffer->context()->scale(FloatSize(static_cast<float>(scaledSize.width()) /
size.width(), |
| 1787 static_cast<float>(scaledSize.height()) / size.height())); | 1766 static_cast<float>(scaledSize.height()) / size.height())); |
| 1788 | 1767 |
| 1789 return buffer.release(); | 1768 return buffer.release(); |
| 1790 } | 1769 } |
| 1791 | 1770 |
| 1792 void GraphicsContext::addCornerArc(SkPath* path, const SkRect& rect, const IntSi
ze& size, int startAngle) | |
| 1793 { | |
| 1794 SkIRect ir; | |
| 1795 int rx = SkMin32(SkScalarRoundToInt(rect.width()), size.width()); | |
| 1796 int ry = SkMin32(SkScalarRoundToInt(rect.height()), size.height()); | |
| 1797 | |
| 1798 ir.set(-rx, -ry, rx, ry); | |
| 1799 switch (startAngle) { | |
| 1800 case 0: | |
| 1801 ir.offset(rect.fRight - ir.fRight, rect.fBottom - ir.fBottom); | |
| 1802 break; | |
| 1803 case 90: | |
| 1804 ir.offset(rect.fLeft - ir.fLeft, rect.fBottom - ir.fBottom); | |
| 1805 break; | |
| 1806 case 180: | |
| 1807 ir.offset(rect.fLeft - ir.fLeft, rect.fTop - ir.fTop); | |
| 1808 break; | |
| 1809 case 270: | |
| 1810 ir.offset(rect.fRight - ir.fRight, rect.fTop - ir.fTop); | |
| 1811 break; | |
| 1812 default: | |
| 1813 ASSERT(0); | |
| 1814 } | |
| 1815 | |
| 1816 SkRect r; | |
| 1817 r.set(ir); | |
| 1818 path->arcTo(r, SkIntToScalar(startAngle), SkIntToScalar(90), false); | |
| 1819 } | |
| 1820 | |
| 1821 void GraphicsContext::setPathFromConvexPoints(SkPath* path, size_t numPoints, co
nst FloatPoint* points) | 1771 void GraphicsContext::setPathFromConvexPoints(SkPath* path, size_t numPoints, co
nst FloatPoint* points) |
| 1822 { | 1772 { |
| 1823 path->incReserve(numPoints); | 1773 path->incReserve(numPoints); |
| 1824 path->moveTo(WebCoreFloatToSkScalar(points[0].x()), | 1774 path->moveTo(WebCoreFloatToSkScalar(points[0].x()), |
| 1825 WebCoreFloatToSkScalar(points[0].y())); | 1775 WebCoreFloatToSkScalar(points[0].y())); |
| 1826 for (size_t i = 1; i < numPoints; ++i) { | 1776 for (size_t i = 1; i < numPoints; ++i) { |
| 1827 path->lineTo(WebCoreFloatToSkScalar(points[i].x()), | 1777 path->lineTo(WebCoreFloatToSkScalar(points[i].x()), |
| 1828 WebCoreFloatToSkScalar(points[i].y())); | 1778 WebCoreFloatToSkScalar(points[i].y())); |
| 1829 } | 1779 } |
| 1830 | 1780 |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2034 | 1984 |
| 2035 void GraphicsContext::didDrawTextInRect(const SkRect& textRect) | 1985 void GraphicsContext::didDrawTextInRect(const SkRect& textRect) |
| 2036 { | 1986 { |
| 2037 if (m_trackTextRegion) { | 1987 if (m_trackTextRegion) { |
| 2038 TRACE_EVENT0("skia", "PlatformContextSkia::trackTextRegion"); | 1988 TRACE_EVENT0("skia", "PlatformContextSkia::trackTextRegion"); |
| 2039 m_textRegion.join(textRect); | 1989 m_textRegion.join(textRect); |
| 2040 } | 1990 } |
| 2041 } | 1991 } |
| 2042 | 1992 |
| 2043 } | 1993 } |
| OLD | NEW |