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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 SkColorFilter* colorFilter = paint.getColorFilter(); | 166 SkColorFilter* colorFilter = paint.getColorFilter(); |
167 if (colorFilter && !(colorFilter->getFlags() & SkColorFilter::kAlphaUnchange
d_Flag)) | 167 if (colorFilter && !(colorFilter->getFlags() & SkColorFilter::kAlphaUnchange
d_Flag)) |
168 return false; | 168 return false; |
169 return true; | 169 return true; |
170 } | 170 } |
171 | 171 |
172 // Returns true if there is a rectangular clip, with the result in |deviceClipRe
ct|. | 172 // Returns true if there is a rectangular clip, with the result in |deviceClipRe
ct|. |
173 static inline bool getDeviceClipAsRect(const GraphicsContext* context, SkRect& d
eviceClipRect) | 173 static inline bool getDeviceClipAsRect(const GraphicsContext* context, SkRect& d
eviceClipRect) |
174 { | 174 { |
175 // Get the current clip in device coordinate space. | 175 // Get the current clip in device coordinate space. |
176 if (!context->canvas()->isClipRect()) | 176 if (!context->canvas()->isClipRect()) { |
| 177 deviceClipRect.setEmpty(); |
177 return false; | 178 return false; |
| 179 } |
178 | 180 |
179 SkIRect deviceClipIRect; | 181 SkIRect deviceClipIRect; |
180 if (context->canvas()->getClipDeviceBounds(&deviceClipIRect)) | 182 if (context->canvas()->getClipDeviceBounds(&deviceClipIRect)) |
181 deviceClipRect.set(deviceClipIRect); | 183 deviceClipRect.set(deviceClipIRect); |
182 else | 184 else |
183 deviceClipRect.setEmpty(); | 185 deviceClipRect.setEmpty(); |
184 | 186 |
185 return true; | 187 return true; |
186 } | 188 } |
187 | 189 |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 SkRect deviceClipRect; | 348 SkRect deviceClipRect; |
347 getDeviceClipAsRect(context, deviceClipRect); | 349 getDeviceClipAsRect(context, deviceClipRect); |
348 markRectAsNonOpaque(deviceClipRect); | 350 markRectAsNonOpaque(deviceClipRect); |
349 } | 351 } |
350 | 352 |
351 void RegionTracker::applyOpaqueRegionFromLayer(const GraphicsContext* context, c
onst SkRect& layerOpaqueRect, const SkPaint& paint) | 353 void RegionTracker::applyOpaqueRegionFromLayer(const GraphicsContext* context, c
onst SkRect& layerOpaqueRect, const SkPaint& paint) |
352 { | 354 { |
353 SkRect deviceClipRect; | 355 SkRect deviceClipRect; |
354 bool deviceClipIsARect = getDeviceClipAsRect(context, deviceClipRect); | 356 bool deviceClipIsARect = getDeviceClipAsRect(context, deviceClipRect); |
355 | 357 |
356 if (deviceClipRect.isEmpty()) | 358 if (deviceClipIsARect && deviceClipRect.isEmpty()) |
357 return; | 359 return; |
358 | 360 |
359 SkRect sourceOpaqueRect = layerOpaqueRect; | 361 SkRect sourceOpaqueRect = layerOpaqueRect; |
360 // Save the opaque area in the destination, so we can preserve the parts of
it under the source opaque area if possible. | 362 // Save the opaque area in the destination, so we can preserve the parts of
it under the source opaque area if possible. |
361 SkRect destinationOpaqueRect = currentTrackingOpaqueRect(); | 363 SkRect destinationOpaqueRect = currentTrackingOpaqueRect(); |
362 | 364 |
363 bool outsideSourceOpaqueRectPreservesOpaque = xfermodePreservesOpaque(paint,
false); | 365 bool outsideSourceOpaqueRectPreservesOpaque = xfermodePreservesOpaque(paint,
false); |
364 if (!outsideSourceOpaqueRectPreservesOpaque) | 366 if (!outsideSourceOpaqueRectPreservesOpaque) { |
| 367 if (!deviceClipIsARect) { |
| 368 markAllAsNonOpaque(); |
| 369 return; |
| 370 } |
365 markRectAsNonOpaque(deviceClipRect); | 371 markRectAsNonOpaque(deviceClipRect); |
| 372 } |
366 | 373 |
367 if (!deviceClipIsARect) | 374 if (!deviceClipIsARect) |
368 return; | 375 return; |
369 if (!sourceOpaqueRect.intersect(deviceClipRect)) | 376 if (!sourceOpaqueRect.intersect(deviceClipRect)) |
370 return; | 377 return; |
371 | 378 |
372 bool sourceOpaqueRectDrawsOpaque = paintIsOpaque(paint, FillOnly, 0); | 379 bool sourceOpaqueRectDrawsOpaque = paintIsOpaque(paint, FillOnly, 0); |
373 bool sourceOpaqueRectXfersOpaque = xfermodeIsOpaque(paint, sourceOpaqueRectD
rawsOpaque); | 380 bool sourceOpaqueRectXfersOpaque = xfermodeIsOpaque(paint, sourceOpaqueRectD
rawsOpaque); |
374 bool sourceOpaqueRectPreservesOpaque = xfermodePreservesOpaque(paint, source
OpaqueRectDrawsOpaque); | 381 bool sourceOpaqueRectPreservesOpaque = xfermodePreservesOpaque(paint, source
OpaqueRectDrawsOpaque); |
375 | 382 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 opaqueRect.setEmpty(); | 468 opaqueRect.setEmpty(); |
462 } | 469 } |
463 | 470 |
464 SkRect& RegionTracker::currentTrackingOpaqueRect() | 471 SkRect& RegionTracker::currentTrackingOpaqueRect() |
465 { | 472 { |
466 // If we are drawing into a canvas layer, then track the opaque rect in that
layer. | 473 // 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; | 474 return m_canvasLayerStack.isEmpty() ? m_opaqueRect : m_canvasLayerStack.last
().opaqueRect; |
468 } | 475 } |
469 | 476 |
470 } // namespace blink | 477 } // namespace blink |
OLD | NEW |