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

Side by Side Diff: Source/platform/graphics/RegionTracker.cpp

Issue 417153002: Avoid passing uninitialized value to markRectAsNonOpaque. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Tests Updated. 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
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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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)
danakj 2014/08/05 13:54:15 What if !deviceClipIsARect but outsideSourceOpaque
sohanjg 2014/08/05 15:23:21 Done. added a test too.
368 return;
369 if (!sourceOpaqueRect.intersect(deviceClipRect)) 374 if (!sourceOpaqueRect.intersect(deviceClipRect))
370 return; 375 return;
371 376
372 bool sourceOpaqueRectDrawsOpaque = paintIsOpaque(paint, FillOnly, 0); 377 bool sourceOpaqueRectDrawsOpaque = paintIsOpaque(paint, FillOnly, 0);
373 bool sourceOpaqueRectXfersOpaque = xfermodeIsOpaque(paint, sourceOpaqueRectD rawsOpaque); 378 bool sourceOpaqueRectXfersOpaque = xfermodeIsOpaque(paint, sourceOpaqueRectD rawsOpaque);
374 bool sourceOpaqueRectPreservesOpaque = xfermodePreservesOpaque(paint, source OpaqueRectDrawsOpaque); 379 bool sourceOpaqueRectPreservesOpaque = xfermodePreservesOpaque(paint, source OpaqueRectDrawsOpaque);
375 380
376 // If the layer's opaque area is being drawn opaque in the layer below, then mark it opaque. Otherwise, 381 // If the layer's opaque area is being drawn opaque in the layer below, then mark it opaque. Otherwise,
377 // if it preserves opaque then keep the intersection of the two. 382 // if it preserves opaque then keep the intersection of the two.
378 if (sourceOpaqueRectXfersOpaque) 383 if (sourceOpaqueRectXfersOpaque)
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 opaqueRect.setEmpty(); 466 opaqueRect.setEmpty();
462 } 467 }
463 468
464 SkRect& RegionTracker::currentTrackingOpaqueRect() 469 SkRect& RegionTracker::currentTrackingOpaqueRect()
465 { 470 {
466 // If we are drawing into a canvas layer, then track the opaque rect in that layer. 471 // 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; 472 return m_canvasLayerStack.isEmpty() ? m_opaqueRect : m_canvasLayerStack.last ().opaqueRect;
468 } 473 }
469 474
470 } // namespace blink 475 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698