| 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 // Paint callback functions | 61 // Paint callback functions |
| 62 | 62 |
| 63 struct PaintFillOpaque : public PaintCallback { | 63 struct PaintFillOpaque : public PaintCallback { |
| 64 virtual void operator()(GraphicsContext& context, const IntRect& contentRect
) OVERRIDE | 64 virtual void operator()(GraphicsContext& context, const IntRect& contentRect
) OVERRIDE |
| 65 { | 65 { |
| 66 Color opaque(255, 0, 0, 255); | 66 Color opaque(255, 0, 0, 255); |
| 67 IntRect top(contentRect.x(), contentRect.y(), contentRect.width(), conte
ntRect.height() / 2); | 67 IntRect top(contentRect.x(), contentRect.y(), contentRect.width(), conte
ntRect.height() / 2); |
| 68 IntRect bottom(contentRect.x(), contentRect.y() + contentRect.height() /
2, contentRect.width(), contentRect.height() / 2); | 68 IntRect bottom(contentRect.x(), contentRect.y() + contentRect.height() /
2, contentRect.width(), contentRect.height() / 2); |
| 69 context.fillRect(top, opaque, ColorSpaceDeviceRGB); | 69 context.fillRect(top, opaque); |
| 70 context.fillRect(bottom, opaque, ColorSpaceDeviceRGB); | 70 context.fillRect(bottom, opaque); |
| 71 } | 71 } |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 struct PaintFillAlpha : public PaintCallback { | 74 struct PaintFillAlpha : public PaintCallback { |
| 75 virtual void operator()(GraphicsContext& context, const IntRect& contentRect
) | 75 virtual void operator()(GraphicsContext& context, const IntRect& contentRect
) |
| 76 { | 76 { |
| 77 Color alpha(0, 0, 0, 0); | 77 Color alpha(0, 0, 0, 0); |
| 78 context.fillRect(contentRect, alpha, ColorSpaceDeviceRGB); | 78 context.fillRect(contentRect, alpha); |
| 79 } | 79 } |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 struct PaintFillPartialOpaque : public PaintCallback { | 82 struct PaintFillPartialOpaque : public PaintCallback { |
| 83 PaintFillPartialOpaque(IntRect opaqueRect) | 83 PaintFillPartialOpaque(IntRect opaqueRect) |
| 84 : m_opaqueRect(opaqueRect) | 84 : m_opaqueRect(opaqueRect) |
| 85 { | 85 { |
| 86 } | 86 } |
| 87 | 87 |
| 88 virtual void operator()(GraphicsContext& context, const IntRect& contentRect
) | 88 virtual void operator()(GraphicsContext& context, const IntRect& contentRect
) |
| 89 { | 89 { |
| 90 Color alpha(0, 0, 0, 0); | 90 Color alpha(0, 0, 0, 0); |
| 91 context.fillRect(contentRect, alpha, ColorSpaceDeviceRGB); | 91 context.fillRect(contentRect, alpha); |
| 92 | 92 |
| 93 IntRect fillOpaque = m_opaqueRect; | 93 IntRect fillOpaque = m_opaqueRect; |
| 94 fillOpaque.intersect(contentRect); | 94 fillOpaque.intersect(contentRect); |
| 95 | 95 |
| 96 Color opaque(255, 255, 255, 255); | 96 Color opaque(255, 255, 255, 255); |
| 97 context.fillRect(fillOpaque, opaque, ColorSpaceDeviceRGB); | 97 context.fillRect(fillOpaque, opaque); |
| 98 } | 98 } |
| 99 | 99 |
| 100 IntRect m_opaqueRect; | 100 IntRect m_opaqueRect; |
| 101 }; | 101 }; |
| 102 | 102 |
| 103 #define EXPECT_EQ_RECT(a, b) \ | 103 #define EXPECT_EQ_RECT(a, b) \ |
| 104 EXPECT_EQ(a.x, b.x); \ | 104 EXPECT_EQ(a.x, b.x); \ |
| 105 EXPECT_EQ(a.width, b.width); \ | 105 EXPECT_EQ(a.width, b.width); \ |
| 106 EXPECT_EQ(a.y, b.y); \ | 106 EXPECT_EQ(a.y, b.y); \ |
| 107 EXPECT_EQ(a.height, b.height); | 107 EXPECT_EQ(a.height, b.height); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 TestLayerPainterChromium painter(fillPartial); | 188 TestLayerPainterChromium painter(fillPartial); |
| 189 OpaqueRectTrackingContentLayerDelegate delegate(&painter); | 189 OpaqueRectTrackingContentLayerDelegate delegate(&painter); |
| 190 | 190 |
| 191 WebFloatRect opaqueRect; | 191 WebFloatRect opaqueRect; |
| 192 WebRect contentRect(11, 12, 389, 388); | 192 WebRect contentRect(11, 12, 389, 388); |
| 193 delegate.paintContents(skCanvas(), contentRect, false, opaqueRect); | 193 delegate.paintContents(skCanvas(), contentRect, false, opaqueRect); |
| 194 EXPECT_EQ_RECT(WebFloatRect(partialRect.x(), partialRect.y(), partialRect.wi
dth(), partialRect.height()), opaqueRect); | 194 EXPECT_EQ_RECT(WebFloatRect(partialRect.x(), partialRect.y(), partialRect.wi
dth(), partialRect.height()), opaqueRect); |
| 195 } | 195 } |
| 196 | 196 |
| 197 } // namespace | 197 } // namespace |
| OLD | NEW |