| 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 1615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1626 p1.setX(p1.x() + 0.5f); | 1626 p1.setX(p1.x() + 0.5f); |
| 1627 p2.setX(p2.x() + 0.5f); | 1627 p2.setX(p2.x() + 0.5f); |
| 1628 } else { | 1628 } else { |
| 1629 // We're a horizontal line. Adjust our y. | 1629 // We're a horizontal line. Adjust our y. |
| 1630 p1.setY(p1.y() + 0.5f); | 1630 p1.setY(p1.y() + 0.5f); |
| 1631 p2.setY(p2.y() + 0.5f); | 1631 p2.setY(p2.y() + 0.5f); |
| 1632 } | 1632 } |
| 1633 } | 1633 } |
| 1634 } | 1634 } |
| 1635 | 1635 |
| 1636 PassOwnPtr<ImageBuffer> GraphicsContext::createCompatibleBuffer(const IntSize& s
ize, OpacityMode opacityMode) const | 1636 PassOwnPtr<ImageBuffer> GraphicsContext::createRasterBuffer(const IntSize& size,
OpacityMode opacityMode) const |
| 1637 { | 1637 { |
| 1638 // Make the buffer larger if the context's transform is scaling it so we nee
d a higher | 1638 // Make the buffer larger if the context's transform is scaling it so we nee
d a higher |
| 1639 // resolution than one pixel per unit. Also set up a corresponding scale fac
tor on the | 1639 // resolution than one pixel per unit. Also set up a corresponding scale fac
tor on the |
| 1640 // graphics context. | 1640 // graphics context. |
| 1641 | 1641 |
| 1642 AffineTransform transform = getCTM(); | 1642 AffineTransform transform = getCTM(); |
| 1643 IntSize scaledSize(static_cast<int>(ceil(size.width() * transform.xScale()))
, static_cast<int>(ceil(size.height() * transform.yScale()))); | 1643 IntSize scaledSize(static_cast<int>(ceil(size.width() * transform.xScale()))
, static_cast<int>(ceil(size.height() * transform.yScale()))); |
| 1644 | 1644 |
| 1645 SkAlphaType alphaType = (opacityMode == Opaque) ? kOpaque_SkAlphaType : kPre
mul_SkAlphaType; | 1645 SkAlphaType alphaType = (opacityMode == Opaque) ? kOpaque_SkAlphaType : kPre
mul_SkAlphaType; |
| 1646 SkImageInfo info = SkImageInfo::MakeN32(size.width(), size.height(), alphaTy
pe); | 1646 SkImageInfo info = SkImageInfo::MakeN32(size.width(), size.height(), alphaTy
pe); |
| 1647 RefPtr<SkSurface> skSurface = adoptRef(m_canvas->newSurface(info)); | 1647 RefPtr<SkSurface> skSurface = adoptRef(SkSurface::NewRaster(info)); |
| 1648 if (!skSurface) | 1648 if (!skSurface) |
| 1649 return nullptr; | 1649 return nullptr; |
| 1650 OwnPtr<ImageBufferSurface> surface = adoptPtr(new CompatibleImageBufferSurfa
ce(skSurface.release(), scaledSize, opacityMode)); | 1650 OwnPtr<ImageBufferSurface> surface = adoptPtr(new CompatibleImageBufferSurfa
ce(skSurface.release(), scaledSize, opacityMode)); |
| 1651 ASSERT(surface->isValid()); | 1651 ASSERT(surface->isValid()); |
| 1652 OwnPtr<ImageBuffer> buffer = adoptPtr(new ImageBuffer(surface.release())); | 1652 OwnPtr<ImageBuffer> buffer = adoptPtr(new ImageBuffer(surface.release())); |
| 1653 | 1653 |
| 1654 buffer->context()->scale(static_cast<float>(scaledSize.width()) / size.width
(), | 1654 buffer->context()->scale(static_cast<float>(scaledSize.width()) / size.width
(), |
| 1655 static_cast<float>(scaledSize.height()) / size.height()); | 1655 static_cast<float>(scaledSize.height()) / size.height()); |
| 1656 | 1656 |
| 1657 return buffer.release(); | 1657 return buffer.release(); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1826 | 1826 |
| 1827 void GraphicsContext::didDrawTextInRect(const SkRect& textRect) | 1827 void GraphicsContext::didDrawTextInRect(const SkRect& textRect) |
| 1828 { | 1828 { |
| 1829 if (m_trackTextRegion) { | 1829 if (m_trackTextRegion) { |
| 1830 TRACE_EVENT0("skia", "GraphicsContext::didDrawTextInRect"); | 1830 TRACE_EVENT0("skia", "GraphicsContext::didDrawTextInRect"); |
| 1831 m_textRegion.join(textRect); | 1831 m_textRegion.join(textRect); |
| 1832 } | 1832 } |
| 1833 } | 1833 } |
| 1834 | 1834 |
| 1835 } | 1835 } |
| OLD | NEW |