Chromium Code Reviews| 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 | 26 |
| 27 namespace blink { | 27 namespace blink { |
| 28 | 28 |
| 29 LocalCurrentGraphicsContext::LocalCurrentGraphicsContext(GraphicsContext& graphi csContext, const IntRect& dirtyRect) | 29 LocalCurrentGraphicsContext::LocalCurrentGraphicsContext(GraphicsContext& graphi csContext, const IntRect& dirtyRect) |
| 30 : LocalCurrentGraphicsContext(graphicsContext.canvas(), graphicsContext.devi ceScaleFactor(), nullptr, dirtyRect) | 30 : LocalCurrentGraphicsContext(graphicsContext.canvas(), graphicsContext.devi ceScaleFactor(), dirtyRect) |
| 31 { | 31 { |
| 32 } | 32 } |
| 33 | 33 |
| 34 LocalCurrentGraphicsContext::LocalCurrentGraphicsContext(GraphicsContext& graphi csContext, const IntRect* interestRect, | 34 static const int kPixelDistanceToClamp = 4000; |
| 35 const IntRect& dirtyRec t) | |
| 36 : LocalCurrentGraphicsContext(graphicsContext.canvas(), graphicsContext.devi ceScaleFactor(), interestRect, dirtyRect) | |
| 37 { | |
| 38 } | |
| 39 | 35 |
| 40 LocalCurrentGraphicsContext::LocalCurrentGraphicsContext(SkCanvas* canvas, float deviceScaleFactor, const IntRect* interestRect, | 36 LocalCurrentGraphicsContext::LocalCurrentGraphicsContext(SkCanvas* canvas, float deviceScaleFactor, const IntRect& dirtyRect) |
| 41 const IntRect& dirtyRec t) | |
| 42 : m_didSetGraphicsContext(false) | 37 : m_didSetGraphicsContext(false) |
| 43 , m_inflatedDirtyRect(ThemeMac::inflateRectForAA(dirtyRect)) | 38 , m_inflatedDirtyRect(ThemeMac::inflateRectForAA(dirtyRect)) |
| 44 , m_skiaBitLocker(canvas, | 39 , m_skiaBitLocker(canvas, |
| 45 m_inflatedDirtyRect, | 40 m_inflatedDirtyRect, |
| 46 deviceScaleFactor) | 41 deviceScaleFactor) |
| 47 { | 42 { |
| 48 m_savedCanvas = canvas; | 43 m_savedCanvas = canvas; |
| 49 canvas->save(); | 44 canvas->save(); |
| 50 | 45 |
| 51 bool clipToInterest = interestRect && !interestRect->contains(m_inflatedDirt yRect); | 46 IntRect clampRect(0, 0, kPixelDistanceToClamp, kPixelDistanceToClamp); |
| 52 if (clipToInterest) { | 47 if (!clampRect.contains(m_inflatedDirtyRect)) { |
|
chrishtr
2016/05/05 23:50:58
I think you need to adjust clampRect by the paint
wkorman
2016/05/06 22:42:55
Reworked this and added a comment.
| |
| 53 IntRect clippedBounds(m_inflatedDirtyRect); | 48 IntRect clippedBounds(m_inflatedDirtyRect); |
| 54 clippedBounds.intersect(*interestRect); | 49 clippedBounds.intersect(clampRect); |
| 55 canvas->clipRect(clippedBounds, SkRegion::kIntersect_Op); | 50 canvas->clipRect(clippedBounds, SkRegion::kIntersect_Op); |
| 56 } | 51 } |
| 57 | 52 |
| 58 CGContextRef cgContext = this->cgContext(); | 53 CGContextRef cgContext = this->cgContext(); |
| 59 if (cgContext == [[NSGraphicsContext currentContext] graphicsPort]) { | 54 if (cgContext == [[NSGraphicsContext currentContext] graphicsPort]) { |
| 60 m_savedNSGraphicsContext = 0; | 55 m_savedNSGraphicsContext = 0; |
| 61 return; | 56 return; |
| 62 } | 57 } |
| 63 | 58 |
| 64 m_savedNSGraphicsContext = [[NSGraphicsContext currentContext] retain]; | 59 m_savedNSGraphicsContext = [[NSGraphicsContext currentContext] retain]; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 80 CGContextRef LocalCurrentGraphicsContext::cgContext() | 75 CGContextRef LocalCurrentGraphicsContext::cgContext() |
| 81 { | 76 { |
| 82 // This synchronizes the CGContext to reflect the current SkCanvas state. | 77 // This synchronizes the CGContext to reflect the current SkCanvas state. |
| 83 // The implementation may not return the same CGContext each time. | 78 // The implementation may not return the same CGContext each time. |
| 84 CGContextRef cgContext = m_skiaBitLocker.cgContext(); | 79 CGContextRef cgContext = m_skiaBitLocker.cgContext(); |
| 85 | 80 |
| 86 return cgContext; | 81 return cgContext; |
| 87 } | 82 } |
| 88 | 83 |
| 89 } | 84 } |
| OLD | NEW |