OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012, Google Inc. All rights reserved. | 2 * Copyright (c) 2012, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 | 46 |
47 void RegionTracker::reset() | 47 void RegionTracker::reset() |
48 { | 48 { |
49 ASSERT(m_canvasLayerStack.isEmpty()); | 49 ASSERT(m_canvasLayerStack.isEmpty()); |
50 m_opaqueRect = SkRect::MakeEmpty(); | 50 m_opaqueRect = SkRect::MakeEmpty(); |
51 } | 51 } |
52 | 52 |
53 IntRect RegionTracker::asRect() const | 53 IntRect RegionTracker::asRect() const |
54 { | 54 { |
55 // Returns the largest enclosed rect. | 55 // Returns the largest enclosed rect. |
56 // TODO: actually, this logic looks like its returning the smallest. | 56 |
57 // to return largest, shouldn't we take floor of left/top | 57 // epsilon is large enough to accommodate machine precision issues and |
58 // and the ceil of right/bottom? | 58 // small enough to have a negligible effect on rendered results. |
59 int left = SkScalarCeilToInt(m_opaqueRect.fLeft); | 59 const SkScalar epsilon = 1.0f / 512.0f; |
60 int top = SkScalarCeilToInt(m_opaqueRect.fTop); | 60 |
61 int right = SkScalarFloorToInt(m_opaqueRect.fRight); | 61 int left = SkScalarCeilToInt(m_opaqueRect.fLeft - epsilon); |
62 int bottom = SkScalarFloorToInt(m_opaqueRect.fBottom); | 62 int top = SkScalarCeilToInt(m_opaqueRect.fTop - epsilon); |
| 63 int right = SkScalarFloorToInt(m_opaqueRect.fRight + epsilon); |
| 64 int bottom = SkScalarFloorToInt(m_opaqueRect.fBottom + epsilon); |
63 return IntRect(left, top, right-left, bottom-top); | 65 return IntRect(left, top, right-left, bottom-top); |
64 } | 66 } |
65 | 67 |
66 // Returns true if the xfermode will force the dst to be opaque, regardless of t
he current dst. | 68 // Returns true if the xfermode will force the dst to be opaque, regardless of t
he current dst. |
67 static inline bool xfermodeIsOpaque(const SkPaint& paint, bool srcIsOpaque) | 69 static inline bool xfermodeIsOpaque(const SkPaint& paint, bool srcIsOpaque) |
68 { | 70 { |
69 if (!srcIsOpaque) | 71 if (!srcIsOpaque) |
70 return false; | 72 return false; |
71 | 73 |
72 SkXfermode* xfermode = paint.getXfermode(); | 74 SkXfermode* xfermode = paint.getXfermode(); |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 opaqueRect.setEmpty(); | 463 opaqueRect.setEmpty(); |
462 } | 464 } |
463 | 465 |
464 SkRect& RegionTracker::currentTrackingOpaqueRect() | 466 SkRect& RegionTracker::currentTrackingOpaqueRect() |
465 { | 467 { |
466 // If we are drawing into a canvas layer, then track the opaque rect in that
layer. | 468 // If we are drawing into a canvas layer, then track the opaque rect in that
layer. |
467 return m_canvasLayerStack.isEmpty() ? m_opaqueRect : m_canvasLayerStack.last
().opaqueRect; | 469 return m_canvasLayerStack.isEmpty() ? m_opaqueRect : m_canvasLayerStack.last
().opaqueRect; |
468 } | 470 } |
469 | 471 |
470 } // namespace blink | 472 } // namespace blink |
OLD | NEW |