Changeset 39713 in webkit
- Timestamp:
- Jan 8, 2009 11:45:23 AM (15 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r39712 r39713 1 2009-01-08 Dimitri Glazkov <dglazkov@chromium.org> 2 3 Reviewed by Eric Seidel. 4 5 Commit the right files this time! (Instead of the ugly unfixed ones.) 6 https://bugs.webkit.org/show_bug.cgi?id=23191 7 8 * platform/graphics/skia/BitmapImageSingleFrameSkia.h: 9 * platform/graphics/skia/FloatPointSkia.cpp: 10 * platform/graphics/skia/FloatRectSkia.cpp: 11 * platform/graphics/skia/IntPointSkia.cpp: 12 * platform/graphics/skia/IntRectSkia.cpp: 13 (WebCore::IntRect::operator SkRect): 14 * platform/graphics/skia/SkiaUtils.cpp: 15 (WebCore::): 16 (WebCore::WebCoreCompositeToSkiaComposite): 17 (WebCore::SkPMColorToWebCoreColor): 18 (WebCore::IntersectRectAndRegion): 19 (WebCore::ClipRectToCanvas): 20 (WebCore::SkPathContainsPoint): 21 (WebCore::scratchContext): 22 * platform/graphics/skia/SkiaUtils.h: 23 (WebCore::WebCoreFloatToSkScalar): 24 (WebCore::WebCoreDoubleToSkScalar): 25 1 26 2009-01-08 Dimitri Glazkov <dglazkov@chromium.org> 2 27 … … 5 30 Add the first few files from platform/graphics/skia 6 31 https://bugs.webkit.org/show_bug.cgi?id=23191 7 32 8 33 These are all pretty simple. 9 34 Eventually BitmapImageSingleFrameSkia might grow a .cpp file, for now it's just a header. -
trunk/WebCore/platform/graphics/skia/BitmapImageSingleFrameSkia.h
r39712 r39713 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 1 /* 2 * Copyright (c) 2006,2007,2008, Google Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: 7 * 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above 11 * copyright notice, this list of conditions and the following disclaimer 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * * Neither the name of Google Inc. nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 4 30 5 31 #ifndef BitmapImageSingleFrameSkia_h … … 23 49 // Creates a new Image, by copying the pixel values out of |bitmap|. 24 50 // If creation failed, returns null. 25 static PassRefPtr<BitmapImageSingleFrameSkia> create( 26 const SkBitmap& bitmap); 51 static PassRefPtr<BitmapImageSingleFrameSkia> create(const SkBitmap&); 27 52 28 53 virtual bool isBitmapImage() const { return true; } … … 48 73 49 74 protected: 50 virtual void draw(GraphicsContext* ctxt, const FloatRect& dstRect, 51 const FloatRect& srcRect, CompositeOperator compositeOp); 75 virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, CompositeOperator); 52 76 53 77 private: -
trunk/WebCore/platform/graphics/skia/FloatPointSkia.cpp
r39712 r39713 1 1 /* 2 * Copyright ( C) 2008 Google, Inc.All rights reserved.3 * 2 * Copyright (c) 2008, Google Inc. All rights reserved. 3 * 4 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 5 * modification, are permitted provided that the following conditions are 6 * met: 7 * 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above 11 * copyright notice, this list of conditions and the following disclaimer 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * * Neither the name of Google Inc. nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 29 */ 25 30 … … 45 50 46 51 } // namespace WebCore 47 -
trunk/WebCore/platform/graphics/skia/FloatRectSkia.cpp
r39712 r39713 1 1 /* 2 * Copyright ( C) 2008 Google, Inc.All rights reserved.3 * 2 * Copyright (c) 2008, Google Inc. All rights reserved. 3 * 4 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 5 * modification, are permitted provided that the following conditions are 6 * met: 7 * 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above 11 * copyright notice, this list of conditions and the following disclaimer 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * * Neither the name of Google Inc. nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. … … 44 49 45 50 } // namespace WebCore 46 -
trunk/WebCore/platform/graphics/skia/IntPointSkia.cpp
r39712 r39713 1 1 /* 2 * Copyright ( C) 2008 Google, Inc.All rights reserved.3 * 2 * Copyright (c) 2008, Google Inc. All rights reserved. 3 * 4 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 5 * modification, are permitted provided that the following conditions are 6 * met: 7 * 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above 11 * copyright notice, this list of conditions and the following disclaimer 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * * Neither the name of Google Inc. nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 29 */ 25 30 26 31 #include "config.h" 27 32 #include "IntPoint.h" 33 28 34 #include "SkPoint.h" 29 35 -
trunk/WebCore/platform/graphics/skia/IntRectSkia.cpp
r39712 r39713 1 1 /* 2 * Copyright ( C) 2008 Google, Inc.All rights reserved.3 * 2 * Copyright (c) 2008, Google Inc. All rights reserved. 3 * 4 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 5 * modification, are permitted provided that the following conditions are 6 * met: 7 * 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above 11 * copyright notice, this list of conditions and the following disclaimer 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * * Neither the name of Google Inc. nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 29 */ 25 30 … … 40 45 { 41 46 SkRect rect; 42 rect.set(SkIntToScalar(x()), SkIntToScalar(y()), 43 SkIntToScalar(right()), SkIntToScalar(bottom())); 47 rect.set(SkIntToScalar(x()), SkIntToScalar(y()), SkIntToScalar(right()), SkIntToScalar(bottom())); 44 48 return rect; 45 49 } … … 51 55 } 52 56 53 } 54 57 } // namespace WebCore -
trunk/WebCore/platform/graphics/skia/SkiaUtils.cpp
r39712 r39713 1 // Copyright (c) 2008, Google Inc. 2 // All rights reserved. 3 // 4 // Redistribution and use in source and binary forms, with or without 5 // modification, are permitted provided that the following conditions are 6 // met: 7 // 8 // * Redistributions of source code must retain the above copyright 9 // notice, this list of conditions and the following disclaimer. 10 // * Redistributions in binary form must reproduce the above 11 // copyright notice, this list of conditions and the following disclaimer 12 // in the documentation and/or other materials provided with the 13 // distribution. 14 // * Neither the name of Google Inc. nor the names of its 15 // contributors may be used to endorse or promote products derived from 16 // this software without specific prior written permission. 17 // 18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 1 /* 2 * Copyright (c) 2006,2007,2008, Google Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: 7 * 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above 11 * copyright notice, this list of conditions and the following disclaimer 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * * Neither the name of Google Inc. nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 29 30 30 31 #include "config.h" … … 41 42 namespace WebCore { 42 43 43 void WebCorePointToSkiaPoint(const WebCore::FloatPoint& src, SkPoint* dst)44 {45 dst->set(WebCoreFloatToSkScalar(src.x()), WebCoreFloatToSkScalar(src.y()));46 }47 48 void WebCoreRectToSkiaRect(const WebCore::IntRect& src, SkRect* dst)49 {50 dst->set(SkIntToScalar(src.x()),51 SkIntToScalar(src.y()),52 SkIntToScalar(src.x() + src.width()),53 SkIntToScalar(src.y() + src.height()));54 }55 56 void WebCoreRectToSkiaRect(const WebCore::IntRect& src, SkIRect* dst)57 {58 dst->set(src.x(),59 src.y(),60 src.x() + src.width(),61 src.y() + src.height());62 }63 64 void WebCoreRectToSkiaRect(const WebCore::FloatRect& src, SkRect* dst)65 {66 dst->set(WebCoreFloatToSkScalar(src.x()),67 WebCoreFloatToSkScalar(src.y()),68 WebCoreFloatToSkScalar(src.x() + src.width()),69 WebCoreFloatToSkScalar(src.y() + src.height()));70 }71 72 void WebCoreRectToSkiaRect(const WebCore::FloatRect& src, SkIRect* dst)73 {74 dst->set(SkScalarRound(WebCoreFloatToSkScalar(src.x())),75 SkScalarRound(WebCoreFloatToSkScalar(src.y())),76 SkScalarRound(WebCoreFloatToSkScalar(src.x() + src.width())),77 SkScalarRound(WebCoreFloatToSkScalar(src.y() + src.height())));78 }79 80 44 static const struct CompositOpToPorterDuffMode { 81 45 uint8_t mCompositOp; 82 46 uint8_t mPorterDuffMode; 83 47 } gMapCompositOpsToPorterDuffModes[] = { 84 { WebCore::CompositeClear, SkPorterDuff::kClear_Mode },85 { WebCore::CompositeCopy, SkPorterDuff::kSrcOver_Mode }, // TODO86 { WebCore::CompositeSourceOver, SkPorterDuff::kSrcOver_Mode },87 { WebCore::CompositeSourceIn, SkPorterDuff::kSrcIn_Mode },88 { WebCore::CompositeSourceOut, SkPorterDuff::kSrcOut_Mode },89 { WebCore::CompositeSourceAtop, SkPorterDuff::kSrcATop_Mode },90 { WebCore::CompositeDestinationOver, SkPorterDuff::kDstOver_Mode },91 { WebCore::CompositeDestinationIn, SkPorterDuff::kDstIn_Mode },92 { WebCore::CompositeDestinationOut, SkPorterDuff::kDstOut_Mode },93 { WebCore::CompositeDestinationAtop, SkPorterDuff::kDstATop_Mode },94 { WebCore::CompositeXOR, SkPorterDuff::kXor_Mode },95 { WebCore::CompositePlusDarker, SkPorterDuff::kDarken_Mode },96 { WebCore::CompositeHighlight, SkPorterDuff::kSrcOver_Mode }, // TODO97 { WebCore::CompositePlusLighter, SkPorterDuff::kLighten_Mode }48 { CompositeClear, SkPorterDuff::kClear_Mode }, 49 { CompositeCopy, SkPorterDuff::kSrcOver_Mode }, // TODO 50 { CompositeSourceOver, SkPorterDuff::kSrcOver_Mode }, 51 { CompositeSourceIn, SkPorterDuff::kSrcIn_Mode }, 52 { CompositeSourceOut, SkPorterDuff::kSrcOut_Mode }, 53 { CompositeSourceAtop, SkPorterDuff::kSrcATop_Mode }, 54 { CompositeDestinationOver, SkPorterDuff::kDstOver_Mode }, 55 { CompositeDestinationIn, SkPorterDuff::kDstIn_Mode }, 56 { CompositeDestinationOut, SkPorterDuff::kDstOut_Mode }, 57 { CompositeDestinationAtop, SkPorterDuff::kDstATop_Mode }, 58 { CompositeXOR, SkPorterDuff::kXor_Mode }, 59 { CompositePlusDarker, SkPorterDuff::kDarken_Mode }, 60 { CompositeHighlight, SkPorterDuff::kSrcOver_Mode }, // TODO 61 { CompositePlusLighter, SkPorterDuff::kLighten_Mode } 98 62 }; 99 63 100 SkPorterDuff::Mode WebCoreCompositeToSkiaComposite( WebCore::CompositeOperator op)64 SkPorterDuff::Mode WebCoreCompositeToSkiaComposite(CompositeOperator op) 101 65 { 102 66 const CompositOpToPorterDuffMode* table = gMapCompositOpsToPorterDuffModes; 103 67 104 68 for (unsigned i = 0; i < SK_ARRAY_COUNT(gMapCompositOpsToPorterDuffModes); i++) { 105 if (table[i].mCompositOp == op) {69 if (table[i].mCompositOp == op) 106 70 return (SkPorterDuff::Mode)table[i].mPorterDuffMode; 107 }108 71 } 109 72 110 SkDEBUGF(("GraphicsContext::setCompositeOperation uknown Composit Operator %d\n", op));73 SkDEBUGF(("GraphicsContext::setCompositeOperation uknown CompositeOperator %d\n", op)); 111 74 return SkPorterDuff::kSrcOver_Mode; // fall-back 112 75 } … … 132 95 } 133 96 134 WebCore::Color SkPMColorToWebCoreColor(SkPMColor pm)97 Color SkPMColorToWebCoreColor(SkPMColor pm) 135 98 { 136 99 return SkPMColorToColor(pm); 137 100 } 138 101 139 void IntersectRectAndRegion(const SkRegion& region, const SkRect& src_rect, 140 SkRect* dest_rect) { 102 void IntersectRectAndRegion(const SkRegion& region, const SkRect& srcRect, SkRect* destRect) { 141 103 // The cliperator requires an int rect, so we round out. 142 SkIRect src _rect_rounded;143 src _rect.roundOut(&src_rect_rounded);104 SkIRect srcRectRounded; 105 srcRect.roundOut(&srcRectRounded); 144 106 145 107 // The Cliperator will iterate over a bunch of rects where our transformed 146 108 // rect and the clipping region (which may be non-square) overlap. 147 SkRegion::Cliperator cliperator(region, src _rect_rounded);109 SkRegion::Cliperator cliperator(region, srcRectRounded); 148 110 if (cliperator.done()) { 149 dest _rect->setEmpty();111 destRect->setEmpty(); 150 112 return; 151 113 } 152 114 153 115 // Get the union of all visible rects in the clip that overlap our bitmap. 154 SkIRect cur _visible_rect = cliperator.rect();116 SkIRect currentVisibleRect = cliperator.rect(); 155 117 cliperator.next(); 156 118 while (!cliperator.done()) { 157 cur _visible_rect.join(cliperator.rect());119 currentVisibleRect.join(cliperator.rect()); 158 120 cliperator.next(); 159 121 } 160 122 161 dest _rect->set(cur_visible_rect);123 destRect->set(currentVisibleRect); 162 124 } 163 125 164 void ClipRectToCanvas(const SkCanvas& canvas, const SkRect& src_rect, 165 SkRect* dest_rect) { 126 void ClipRectToCanvas(const SkCanvas& canvas, const SkRect& srcRect, SkRect* destRect) { 166 127 // Translate into the canvas' coordinate space. This is where the clipping 167 128 // region applies. 168 SkRect transformed _src;169 canvas.getTotalMatrix().mapRect(&transformed _src, src_rect);129 SkRect transformedSrc; 130 canvas.getTotalMatrix().mapRect(&transformedSrc, srcRect); 170 131 171 132 // Do the intersection. 172 SkRect transformed_dest; 173 IntersectRectAndRegion(canvas.getTotalClip(), transformed_src, 174 &transformed_dest); 133 SkRect transformedDest; 134 IntersectRectAndRegion(canvas.getTotalClip(), transformedSrc, &transformedDest); 175 135 176 136 // Now transform it back into world space. 177 SkMatrix inverse _transform;178 canvas.getTotalMatrix().invert(&inverse _transform);179 inverse _transform.mapRect(dest_rect, transformed_dest);137 SkMatrix inverseTransform; 138 canvas.getTotalMatrix().invert(&inverseTransform); 139 inverseTransform.mapRect(destRect, transformedDest); 180 140 } 181 141 182 bool SkPathContainsPoint(SkPath* orig _path, WebCore::FloatPointpoint, SkPath::FillType ft)142 bool SkPathContainsPoint(SkPath* originalPath, const FloatPoint& point, SkPath::FillType ft) 183 143 { 184 SkRegion rgn, clip; 144 SkRegion rgn; 145 SkRegion clip; 185 146 186 SkPath::FillType orig _ft = orig_path->getFillType(); // save147 SkPath::FillType originalFillType = originalPath->getFillType(); 187 148 188 const SkPath* path = orig _path;189 SkPath scaled _path;149 const SkPath* path = originalPath; 150 SkPath scaledPath; 190 151 int scale = 1; 191 152 192 153 SkRect bounds; 193 orig _path->computeBounds(&bounds, SkPath::kFast_BoundsType);154 originalPath->computeBounds(&bounds, SkPath::kFast_BoundsType); 194 155 195 156 // We can immediately return false if the point is outside the bounding rect 196 157 if (!bounds.contains(SkFloatToScalar(point.x()), SkFloatToScalar(point.y()))) 197 return false;158 return false; 198 159 199 orig _path->setFillType(ft);160 originalPath->setFillType(ft); 200 161 201 162 // Skia has trouble with coordinates close to the max signed 16-bit values … … 205 166 // values 206 167 const SkScalar kMaxCoordinate = SkIntToScalar(1<<15); 207 SkScalar biggest_coord = std::max(std::max(std::max( 208 bounds.fRight, bounds.fBottom), -bounds.fLeft), -bounds.fTop); 168 SkScalar biggestCoord = std::max(std::max(std::max(bounds.fRight, bounds.fBottom), -bounds.fLeft), -bounds.fTop); 209 169 210 if (biggest _coord > kMaxCoordinate) {211 scale = SkScalarCeil(SkScalarDiv(biggest_coord, kMaxCoordinate));170 if (biggestCoord > kMaxCoordinate) { 171 scale = SkScalarCeil(SkScalarDiv(biggestCoord, kMaxCoordinate)); 212 172 213 SkMatrix m; 214 m.setScale(SkScalarInvert(SkIntToScalar(scale)), 215 SkScalarInvert(SkIntToScalar(scale))); 216 orig_path->transform(m, &scaled_path); 217 path = &scaled_path; 173 SkMatrix m; 174 m.setScale(SkScalarInvert(SkIntToScalar(scale)), SkScalarInvert(SkIntToScalar(scale))); 175 originalPath->transform(m, &scaledPath); 176 path = &scaledPath; 218 177 } 219 178 220 int x = (int)floorf(point.x() / scale);221 int y = (int)floorf(point.y() / scale);179 int x = static_cast<int>(floorf(point.x() / scale)); 180 int y = static_cast<int>(floorf(point.y() / scale)); 222 181 clip.setRect(x, y, x + 1, y + 1); 223 182 224 183 bool contains = rgn.setPath(*path, clip); 225 184 226 orig _path->setFillType(orig_ft); // restore185 originalPath->setFillType(originalFillType); 227 186 return contains; 228 187 } … … 230 189 GraphicsContext* scratchContext() 231 190 { 232 static ImageBuffer* scratch = NULL;191 static ImageBuffer* scratch = 0; 233 192 if (!scratch) 234 193 scratch = ImageBuffer::create(IntSize(1, 1), false).release(); -
trunk/WebCore/platform/graphics/skia/SkiaUtils.h
r39712 r39713 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 1 /* 2 * Copyright (c) 2006,2007,2008, Google Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: 7 * 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above 11 * copyright notice, this list of conditions and the following disclaimer 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * * Neither the name of Google Inc. nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 4 30 5 // This file declares helper routines for using Skia in WebKit.31 // All of the functions in this file should move to new homes and this file should be deleted. 6 32 7 33 #ifndef SkiaUtils_h … … 18 44 namespace WebCore { 19 45 20 // Converts a WebCore composit operation (WebCore::Composite*) to the 21 // corresponding Skia type. 22 SkPorterDuff::Mode WebCoreCompositeToSkiaComposite(WebCore::CompositeOperator); 46 SkPorterDuff::Mode WebCoreCompositeToSkiaComposite(CompositeOperator); 23 47 24 48 // move this guy into SkColor.h 25 SkColor SkPMColorToColor(SkPMColor pm);49 SkColor SkPMColorToColor(SkPMColor); 26 50 27 // Converts Android colors to WebKit ones.28 WebCore::Color SkPMColorToWebCoreColor(SkPMColor pm);51 // This should be an operator on Color 52 Color SkPMColorToWebCoreColor(SkPMColor); 29 53 30 54 // Skia has problems when passed infinite, etc floats, filter them to 0. 31 inline SkScalar WebCoreFloatToSkScalar(const float& f) { 32 return SkFloatToScalar(isfinite(f) ? f : 0); 55 inline SkScalar WebCoreFloatToSkScalar(float f) 56 { 57 return SkFloatToScalar(isfinite(f) ? f : 0); 33 58 } 34 59 35 inline SkScalar WebCoreDoubleToSkScalar(const double& d) { 36 return SkDoubleToScalar(isfinite(d) ? d : 0); 60 inline SkScalar WebCoreDoubleToSkScalar(double d) 61 { 62 return SkDoubleToScalar(isfinite(d) ? d : 0); 37 63 } 38 39 // Intersects the given source rect with the region, returning the smallest40 // rectangular region that encompases the result.41 //42 // src_rect and dest_rect can be the same.43 void IntersectRectAndRegion(const SkRegion& region, const SkRect& src_rect,44 SkRect* dest_rect);45 64 46 65 // Computes the smallest rectangle that, which when drawn to the given canvas, … … 48 67 // clip, doing the necessary coordinate transforms. 49 68 // 50 // src_rect and dest_rect can be the same. 51 void ClipRectToCanvas(const SkCanvas& canvas, const SkRect& src_rect, 52 SkRect* dest_rect); 69 // srcRect and destRect can be the same. 70 void ClipRectToCanvas(const SkCanvas&, const SkRect& srcRect, SkRect* destRect); 53 71 54 72 // Determine if a given WebKit point is contained in a path 55 bool SkPathContainsPoint(SkPath* orig_path, WebCore::FloatPoint point, SkPath::FillType ft);73 bool SkPathContainsPoint(SkPath*, const FloatPoint&, SkPath::FillType); 56 74 57 75 // Returns a statically allocated 1x1 GraphicsContext intended for temporary
Note: See TracChangeset
for help on using the changeset viewer.