KHTML
FloatPoint.cpp
Go to the documentation of this file.00001 /* 00002 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. 00003 * Copyright (C) 2005 Nokia. All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions 00007 * are met: 00008 * 1. Redistributions of source code must retain the above copyright 00009 * notice, this list of conditions and the following disclaimer. 00010 * 2. Redistributions in binary form must reproduce the above copyright 00011 * notice, this list of conditions and the following disclaimer in the 00012 * documentation and/or other materials provided with the distribution. 00013 * 00014 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 00015 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00016 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00017 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 00018 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00019 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00020 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00021 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00022 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00023 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00024 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00025 */ 00026 00027 #include "config.h" 00028 #include "FloatPoint.h" 00029 00030 #include "AffineTransform.h" 00031 #include "FloatConversion.h" 00032 #include "IntPoint.h" 00033 00034 namespace WebCore { 00035 00036 FloatPoint::FloatPoint(const IntPoint& p) : m_x(p.x()), m_y(p.y()) 00037 { 00038 } 00039 00040 FloatPoint FloatPoint::matrixTransform(const AffineTransform& transform) const 00041 { 00042 double newX, newY; 00043 transform.map(static_cast<double>(m_x), static_cast<double>(m_y), &newX, &newY); 00044 return narrowPrecision(newX, newY); 00045 } 00046 00047 FloatPoint FloatPoint::narrowPrecision(double x, double y) 00048 { 00049 return FloatPoint(narrowPrecisionToFloat(x), narrowPrecisionToFloat(y)); 00050 } 00051 00052 }