|
2 | 2 | * Copyright (C) 2009 Apple Inc. All rights reserved.
|
3 | 3 | * (C) 2011 Brent Fulgham <[email protected]>. All rights reserved.
|
4 | 4 | * (C) 2010, 2011 Igalia S.L
|
| 5 | + * (C) 2012 Intel Corporation. All rights reserved. |
5 | 6 | *
|
6 | 7 | * Redistribution and use in source and binary forms, with or without
|
7 | 8 | * modification, are permitted provided that the following conditions
|
@@ -77,10 +78,39 @@ static void dumpBitmap(cairo_surface_t* surface, const char* checksum)
|
77 | 78 | printPNG(data, dataLength, checksum);
|
78 | 79 | }
|
79 | 80 |
|
80 |
| -void TestInvocation::dumpPixelsAndCompareWithExpected(WKImageRef wkImage, WKArrayRef /*repaintRects*/) |
| 81 | +static void paintRepaintRectOverlay(cairo_surface_t* surface, WKArrayRef repaintRects) |
| 82 | +{ |
| 83 | + cairo_t* context = cairo_create(surface); |
| 84 | + |
| 85 | + cairo_push_group(context); |
| 86 | + |
| 87 | + // Paint the gray mask over the original image. |
| 88 | + cairo_set_source_rgba(context, 0, 0, 0, 0.66); |
| 89 | + cairo_paint(context); |
| 90 | + |
| 91 | + // Paint transparent rectangles over the mask to show the repainted regions. |
| 92 | + cairo_set_source_rgba(context, 0, 0, 0, 0); |
| 93 | + cairo_set_operator(context, CAIRO_OPERATOR_SOURCE); |
| 94 | + size_t count = WKArrayGetSize(repaintRects); |
| 95 | + for (size_t i = 0; i < count; ++i) { |
| 96 | + WKRect rect = WKRectGetValue(static_cast<WKRectRef>(WKArrayGetItemAtIndex(repaintRects, i))); |
| 97 | + cairo_rectangle(context, rect.origin.x, rect.origin.y, rect.size.width, rect.size.height); |
| 98 | + cairo_fill(context); |
| 99 | + } |
| 100 | + |
| 101 | + cairo_pop_group_to_source(context); |
| 102 | + cairo_paint(context); |
| 103 | + |
| 104 | + cairo_destroy(context); |
| 105 | +} |
| 106 | + |
| 107 | +void TestInvocation::dumpPixelsAndCompareWithExpected(WKImageRef wkImage, WKArrayRef repaintRects) |
81 | 108 | {
|
82 | 109 | cairo_surface_t* surface = WKImageCreateCairoSurface(wkImage);
|
83 | 110 |
|
| 111 | + if (repaintRects) |
| 112 | + paintRepaintRectOverlay(surface, repaintRects); |
| 113 | + |
84 | 114 | char actualHash[33];
|
85 | 115 | computeMD5HashStringForCairoSurface(surface, actualHash);
|
86 | 116 | if (!compareActualHashToExpectedAndDumpResults(actualHash))
|
|
0 commit comments