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

Side by Side Diff: src/gpu/GrReducedClip.cpp

Issue 2244223004: Make GrReducedClip's gen ID only apply to the element list (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Make GrReducedClip's gen ID only apply to the element list Created 4 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 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrReducedClip.h" 8 #include "GrReducedClip.h"
9 9
10 #include "GrClip.h" 10 #include "GrClip.h"
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 if (element->isAA()) { 309 if (element->isAA()) {
310 --numAAElements; 310 --numAAElements;
311 } 311 }
312 result->popHead(); 312 result->popHead();
313 element = result->headIter().get(); 313 element = result->headIter().get();
314 } 314 }
315 } 315 }
316 } 316 }
317 *requiresAA = numAAElements > 0; 317 *requiresAA = numAAElements > 0;
318 318
319 if (0 == result->count()) {
320 if (initialState == InitialTriState::kAllIn) {
321 *resultGenID = SkClipStack::kWideOpenGenID;
322 } else {
323 *resultGenID = SkClipStack::kEmptyGenID;
324 }
325 }
326
327 SkASSERT(SkClipStack::kInvalidGenID != *resultGenID);
328 SkASSERT(InitialTriState::kUnknown != initialState); 319 SkASSERT(InitialTriState::kUnknown != initialState);
329 return static_cast<GrReducedClip::InitialState>(initialState); 320 return static_cast<GrReducedClip::InitialState>(initialState);
330 } 321 }
331 322
332 /* 323 /*
333 There are plenty of optimizations that could be added here. Maybe flips could be folded into 324 There are plenty of optimizations that could be added here. Maybe flips could be folded into
334 earlier operations. Or would inserting flips and reversing earlier ops ever be a win? Perhaps 325 earlier operations. Or would inserting flips and reversing earlier ops ever be a win? Perhaps
335 for the case where the bounds are kInsideOut_BoundsType. We could restrict earli er operations 326 for the case where the bounds are kInsideOut_BoundsType. We could restrict earli er operations
336 based on later intersect operations, and perhaps remove intersect-rects. We coul d optionally 327 based on later intersect operations, and perhaps remove intersect-rects. We coul d optionally
337 take a rect in case the caller knows a bound on what is to be drawn through this clip. 328 take a rect in case the caller knows a bound on what is to be drawn through this clip.
338 */ 329 */
339 GrReducedClip::GrReducedClip(const SkClipStack& stack, const SkRect& queryBounds ) { 330 GrReducedClip::GrReducedClip(const SkClipStack& stack, const SkRect& queryBounds ) {
340 SkASSERT(!queryBounds.isEmpty()); 331 SkASSERT(!queryBounds.isEmpty());
341
342 // The clip established by the element list might be cached based on the las t
343 // generation id. When we make early returns, we do not know what was the ge neration
344 // id that lead to the state. Make a conservative guess.
345 fGenID = stack.getTopmostGenID();
346 fHasIBounds = false; 332 fHasIBounds = false;
347 333
348 if (stack.isWideOpen()) { 334 if (stack.isWideOpen()) {
349 fInitialState = InitialState::kAllIn; 335 fInitialState = InitialState::kAllIn;
350 return; 336 return;
351 } 337 }
352 338
353 SkClipStack::BoundsType stackBoundsType; 339 SkClipStack::BoundsType stackBoundsType;
354 SkRect stackBounds; 340 SkRect stackBounds;
355 bool iior; 341 bool iior;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 // clip will be enforced by the scissor through fIBounds.) 385 // clip will be enforced by the scissor through fIBounds.)
400 SkAssertResult(tighterQuery.intersect(GrClip::GetPixelBounds(stackBounds ))); 386 SkAssertResult(tighterQuery.intersect(GrClip::GetPixelBounds(stackBounds )));
401 } 387 }
402 388
403 fIBounds = GrClip::GetPixelIBounds(tighterQuery); 389 fIBounds = GrClip::GetPixelIBounds(tighterQuery);
404 SkASSERT(!fIBounds.isEmpty()); // Empty should have been blocked by IsOutsid eClip above. 390 SkASSERT(!fIBounds.isEmpty()); // Empty should have been blocked by IsOutsid eClip above.
405 fHasIBounds = true; 391 fHasIBounds = true;
406 392
407 // Now that we have determined the bounds to use and filtered out the trivia l cases, call the 393 // Now that we have determined the bounds to use and filtered out the trivia l cases, call the
408 // helper that actually walks the stack. 394 // helper that actually walks the stack.
409 fInitialState = reduced_stack_walker(stack, tighterQuery, fIBounds, &fElemen ts, &fGenID, 395 fInitialState = reduced_stack_walker(stack, tighterQuery, fIBounds, &fElemen ts, &fElementsGenID,
410 &fRequiresAA); 396 &fRequiresAA);
411 } 397 }
OLDNEW
« src/gpu/GrReducedClip.h ('K') | « src/gpu/GrReducedClip.h ('k') | tests/ClipStackTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698