| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006 Apple Computer, Inc. | 2 * Copyright (C) 2006 Apple Computer, Inc. |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU Library General Public License | 14 * You should have received a copy of the GNU Library General Public License |
| 15 * along with this library; see the file COPYING.LIB. If not, write to | 15 * along with this library; see the file COPYING.LIB. If not, write to |
| 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
| 18 */ | 18 */ |
| 19 | 19 |
| 20 #include "platform/mac/LocalCurrentGraphicsContext.h" | 20 #include "platform/mac/LocalCurrentGraphicsContext.h" |
| 21 | 21 |
| 22 #include <AppKit/NSGraphicsContext.h> | 22 #include <AppKit/NSGraphicsContext.h> |
| 23 #include "platform/graphics/GraphicsContext.h" | 23 #include "platform/graphics/GraphicsContext.h" |
| 24 #include "platform/mac/ThemeMac.h" | 24 #include "platform/mac/ThemeMac.h" |
| 25 #include "platform_canvas.h" | 25 #include "platform_canvas.h" |
| 26 #include "skia/ext/cdl_canvas.h" |
| 26 | 27 |
| 27 namespace blink { | 28 namespace blink { |
| 28 | 29 |
| 29 LocalCurrentGraphicsContext::LocalCurrentGraphicsContext( | 30 LocalCurrentGraphicsContext::LocalCurrentGraphicsContext( |
| 30 GraphicsContext& graphicsContext, | 31 GraphicsContext& graphicsContext, |
| 31 const IntRect& dirtyRect) | 32 const IntRect& dirtyRect) |
| 32 : LocalCurrentGraphicsContext(graphicsContext.canvas(), | 33 : LocalCurrentGraphicsContext(graphicsContext.canvas(), |
| 33 graphicsContext.deviceScaleFactor(), | 34 graphicsContext.deviceScaleFactor(), |
| 34 dirtyRect) {} | 35 dirtyRect) {} |
| 35 | 36 |
| 36 static IntRect clampRect(int size, const IntRect& rect) { | 37 static IntRect clampRect(int size, const IntRect& rect) { |
| 37 IntRect clampedRect(rect); | 38 IntRect clampedRect(rect); |
| 38 clampedRect.setSize(IntSize(std::min(size, clampedRect.width()), | 39 clampedRect.setSize(IntSize(std::min(size, clampedRect.width()), |
| 39 std::min(size, clampedRect.height()))); | 40 std::min(size, clampedRect.height()))); |
| 40 return clampedRect; | 41 return clampedRect; |
| 41 } | 42 } |
| 42 | 43 |
| 43 static const int kMaxDirtyRectPixelSize = 10000; | 44 static const int kMaxDirtyRectPixelSize = 10000; |
| 44 | 45 |
| 45 LocalCurrentGraphicsContext::LocalCurrentGraphicsContext( | 46 LocalCurrentGraphicsContext::LocalCurrentGraphicsContext( |
| 46 SkCanvas* canvas, | 47 CdlCanvas* canvas, |
| 47 float deviceScaleFactor, | 48 float deviceScaleFactor, |
| 48 const IntRect& dirtyRect) | 49 const IntRect& dirtyRect) |
| 49 : m_didSetGraphicsContext(false), | 50 : m_didSetGraphicsContext(false), |
| 50 m_inflatedDirtyRect(ThemeMac::inflateRectForAA(dirtyRect)), | 51 m_inflatedDirtyRect(ThemeMac::inflateRectForAA(dirtyRect)), |
| 51 m_skiaBitLocker(canvas, m_inflatedDirtyRect, deviceScaleFactor) { | 52 m_skiaBitLocker(canvas, m_inflatedDirtyRect, deviceScaleFactor) { |
| 52 m_savedCanvas = canvas; | 53 m_savedCanvas = canvas; |
| 53 canvas->save(); | 54 canvas->save(); |
| 54 | 55 |
| 55 // Constrain the maximum size of what we paint to something reasonable. This | 56 // Constrain the maximum size of what we paint to something reasonable. This |
| 56 // accordingly means we will not paint the entirety of truly huge native form | 57 // accordingly means we will not paint the entirety of truly huge native form |
| (...skipping 27 matching lines...) Expand all Loading... |
| 84 } | 85 } |
| 85 | 86 |
| 86 CGContextRef LocalCurrentGraphicsContext::cgContext() { | 87 CGContextRef LocalCurrentGraphicsContext::cgContext() { |
| 87 // This synchronizes the CGContext to reflect the current SkCanvas state. | 88 // This synchronizes the CGContext to reflect the current SkCanvas state. |
| 88 // The implementation may not return the same CGContext each time. | 89 // The implementation may not return the same CGContext each time. |
| 89 CGContextRef cgContext = m_skiaBitLocker.cgContext(); | 90 CGContextRef cgContext = m_skiaBitLocker.cgContext(); |
| 90 | 91 |
| 91 return cgContext; | 92 return cgContext; |
| 92 } | 93 } |
| 93 } | 94 } |
| OLD | NEW |