Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Side by Side Diff: Source/platform/graphics/GraphicsContext.cpp

Issue 399213002: Change GraphicsContext::createCompatibleBuffer to return something non-null (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rename Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/platform/graphics/GraphicsContext.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « Source/platform/graphics/GraphicsContext.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698