Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Side by Side Diff: Source/platform/graphics/skia/OpaqueRegionSkia.cpp

Issue 417153002: Avoid passing uninitialized value to markRectAsNonOpaque. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: review comments addressed. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 (deviceClipRect.isEmpty() && deviceClipIsARect)
danakj 2014/07/28 14:03:57 reverse this order
sohanjg 2014/07/30 10:23:46 Done.
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 && !deviceClipIsARect)
343 markRectAsNonOpaque(deviceClipRect); 345 markAllAsNonOpaque();
danakj 2014/07/28 14:03:56 if it is a rect, you need to still do what we did
sohanjg 2014/07/30 10:23:46 Done.
344 346
345 if (!deviceClipIsARect)
346 return;
347 if (!sourceOpaqueRect.intersect(deviceClipRect)) 347 if (!sourceOpaqueRect.intersect(deviceClipRect))
348 return; 348 return;
349 349
350 bool sourceOpaqueRectDrawsOpaque = paintIsOpaque(paint, FillOnly, 0); 350 bool sourceOpaqueRectDrawsOpaque = paintIsOpaque(paint, FillOnly, 0);
351 bool sourceOpaqueRectXfersOpaque = xfermodeIsOpaque(paint, sourceOpaqueRectD rawsOpaque); 351 bool sourceOpaqueRectXfersOpaque = xfermodeIsOpaque(paint, sourceOpaqueRectD rawsOpaque);
352 bool sourceOpaqueRectPreservesOpaque = xfermodePreservesOpaque(paint, source OpaqueRectDrawsOpaque); 352 bool sourceOpaqueRectPreservesOpaque = xfermodePreservesOpaque(paint, source OpaqueRectDrawsOpaque);
353 353
354 // If the layer's opaque area is being drawn opaque in the layer below, then mark it opaque. Otherwise, 354 // 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. 355 // if it preserves opaque then keep the intersection of the two.
356 if (sourceOpaqueRectXfersOpaque) 356 if (sourceOpaqueRectXfersOpaque)
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 opaqueRect.setEmpty(); 439 opaqueRect.setEmpty();
440 } 440 }
441 441
442 SkRect& OpaqueRegionSkia::currentTrackingOpaqueRect() 442 SkRect& OpaqueRegionSkia::currentTrackingOpaqueRect()
443 { 443 {
444 // If we are drawing into a canvas layer, then track the opaque rect in that layer. 444 // 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; 445 return m_canvasLayerStack.isEmpty() ? m_opaqueRect : m_canvasLayerStack.last ().opaqueRect;
446 } 446 }
447 447
448 } // namespace blink 448 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698