Chromium Code Reviews| 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 149 SkColorFilter* colorFilter = paint.getColorFilter(); | 149 SkColorFilter* colorFilter = paint.getColorFilter(); |
| 150 if (colorFilter && !(colorFilter->getFlags() & SkColorFilter::kAlphaUnchange d_Flag)) | 150 if (colorFilter && !(colorFilter->getFlags() & SkColorFilter::kAlphaUnchange d_Flag)) |
| 151 return false; | 151 return false; |
| 152 return true; | 152 return true; |
| 153 } | 153 } |
| 154 | 154 |
| 155 // Returns true if there is a rectangular clip, with the result in |deviceClipRe ct|. | 155 // Returns true if there is a rectangular clip, with the result in |deviceClipRe ct|. |
| 156 static inline bool getDeviceClipAsRect(const GraphicsContext* context, SkRect& d eviceClipRect) | 156 static inline bool getDeviceClipAsRect(const GraphicsContext* context, SkRect& d eviceClipRect) |
| 157 { | 157 { |
| 158 // Get the current clip in device coordinate space. | 158 // Get the current clip in device coordinate space. |
| 159 if (!context->canvas()->isClipRect()) | 159 if (!context->canvas()->isClipRect()) { |
| 160 deviceClipRect.setEmpty(); | |
| 160 return false; | 161 return false; |
| 162 } | |
| 161 | 163 |
| 162 SkIRect deviceClipIRect; | 164 SkIRect deviceClipIRect; |
| 163 if (context->canvas()->getClipDeviceBounds(&deviceClipIRect)) | 165 if (context->canvas()->getClipDeviceBounds(&deviceClipIRect)) |
| 164 deviceClipRect.set(deviceClipIRect); | 166 deviceClipRect.set(deviceClipIRect); |
| 165 else | 167 else |
| 166 deviceClipRect.setEmpty(); | 168 deviceClipRect.setEmpty(); |
| 167 | 169 |
| 168 return true; | 170 return true; |
| 169 } | 171 } |
| 170 | 172 |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 324 SkRect deviceClipRect; | 326 SkRect deviceClipRect; |
| 325 getDeviceClipAsRect(context, deviceClipRect); | 327 getDeviceClipAsRect(context, deviceClipRect); |
| 326 markRectAsNonOpaque(deviceClipRect); | 328 markRectAsNonOpaque(deviceClipRect); |
| 327 } | 329 } |
| 328 | 330 |
| 329 void OpaqueRegionSkia::applyOpaqueRegionFromLayer(const GraphicsContext* context , const SkRect& layerOpaqueRect, const SkPaint& paint) | 331 void OpaqueRegionSkia::applyOpaqueRegionFromLayer(const GraphicsContext* context , const SkRect& layerOpaqueRect, const SkPaint& paint) |
| 330 { | 332 { |
| 331 SkRect deviceClipRect; | 333 SkRect deviceClipRect; |
| 332 bool deviceClipIsARect = getDeviceClipAsRect(context, deviceClipRect); | 334 bool deviceClipIsARect = getDeviceClipAsRect(context, deviceClipRect); |
| 333 | 335 |
| 334 if (deviceClipRect.isEmpty()) | 336 if (deviceClipIsARect && deviceClipRect.isEmpty()) |
| 335 return; | 337 return; |
| 336 | 338 |
| 337 SkRect sourceOpaqueRect = layerOpaqueRect; | 339 SkRect sourceOpaqueRect = layerOpaqueRect; |
| 338 // Save the opaque area in the destination, so we can preserve the parts of it under the source opaque area if possible. | 340 // Save the opaque area in the destination, so we can preserve the parts of it under the source opaque area if possible. |
| 339 SkRect destinationOpaqueRect = currentTrackingOpaqueRect(); | 341 SkRect destinationOpaqueRect = currentTrackingOpaqueRect(); |
| 340 | 342 |
| 341 bool outsideSourceOpaqueRectPreservesOpaque = xfermodePreservesOpaque(paint, false); | 343 bool outsideSourceOpaqueRectPreservesOpaque = xfermodePreservesOpaque(paint, false); |
| 342 if (!outsideSourceOpaqueRectPreservesOpaque) | 344 if (!outsideSourceOpaqueRectPreservesOpaque) { |
| 345 if (!deviceClipIsARect) { | |
| 346 markAllAsNonOpaque(); | |
| 347 return; | |
| 348 } | |
| 343 markRectAsNonOpaque(deviceClipRect); | 349 markRectAsNonOpaque(deviceClipRect); |
| 350 } | |
| 344 | 351 |
| 345 if (!deviceClipIsARect) | |
|
danakj
2014/07/30 13:31:26
We've lost this early out in some cases now. Can y
sohanjg
2014/07/31 15:44:34
Done.
| |
| 346 return; | |
| 347 if (!sourceOpaqueRect.intersect(deviceClipRect)) | 352 if (!sourceOpaqueRect.intersect(deviceClipRect)) |
| 348 return; | 353 return; |
| 349 | 354 |
| 350 bool sourceOpaqueRectDrawsOpaque = paintIsOpaque(paint, FillOnly, 0); | 355 bool sourceOpaqueRectDrawsOpaque = paintIsOpaque(paint, FillOnly, 0); |
| 351 bool sourceOpaqueRectXfersOpaque = xfermodeIsOpaque(paint, sourceOpaqueRectD rawsOpaque); | 356 bool sourceOpaqueRectXfersOpaque = xfermodeIsOpaque(paint, sourceOpaqueRectD rawsOpaque); |
| 352 bool sourceOpaqueRectPreservesOpaque = xfermodePreservesOpaque(paint, source OpaqueRectDrawsOpaque); | 357 bool sourceOpaqueRectPreservesOpaque = xfermodePreservesOpaque(paint, source OpaqueRectDrawsOpaque); |
| 353 | 358 |
| 354 // If the layer's opaque area is being drawn opaque in the layer below, then mark it opaque. Otherwise, | 359 // If the layer's opaque area is being drawn opaque in the layer below, then mark it opaque. Otherwise, |
| 355 // if it preserves opaque then keep the intersection of the two. | 360 // if it preserves opaque then keep the intersection of the two. |
| 356 if (sourceOpaqueRectXfersOpaque) | 361 if (sourceOpaqueRectXfersOpaque) |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 439 opaqueRect.setEmpty(); | 444 opaqueRect.setEmpty(); |
| 440 } | 445 } |
| 441 | 446 |
| 442 SkRect& OpaqueRegionSkia::currentTrackingOpaqueRect() | 447 SkRect& OpaqueRegionSkia::currentTrackingOpaqueRect() |
| 443 { | 448 { |
| 444 // If we are drawing into a canvas layer, then track the opaque rect in that layer. | 449 // If we are drawing into a canvas layer, then track the opaque rect in that layer. |
| 445 return m_canvasLayerStack.isEmpty() ? m_opaqueRect : m_canvasLayerStack.last ().opaqueRect; | 450 return m_canvasLayerStack.isEmpty() ? m_opaqueRect : m_canvasLayerStack.last ().opaqueRect; |
| 446 } | 451 } |
| 447 | 452 |
| 448 } // namespace blink | 453 } // namespace blink |
| OLD | NEW |