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

Side by Side Diff: src/core/SkLiteDL.cpp

Issue 2229003003: SkLiteDL: tiny perf tweak (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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
« 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 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 "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkData.h" 9 #include "SkData.h"
10 #include "SkImageFilter.h" 10 #include "SkImageFilter.h"
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 static void* push(SkTDArray<uint8_t>* bytes, size_t pod, Args&&... args) { 471 static void* push(SkTDArray<uint8_t>* bytes, size_t pod, Args&&... args) {
472 size_t skip = SkAlignPtr(sizeof(T) + pod); 472 size_t skip = SkAlignPtr(sizeof(T) + pod);
473 auto op = (T*)bytes->append(skip); 473 auto op = (T*)bytes->append(skip);
474 new (op) T{ std::forward<Args>(args)... }; 474 new (op) T{ std::forward<Args>(args)... };
475 op->skip = skip; 475 op->skip = skip;
476 return op+1; 476 return op+1;
477 } 477 }
478 478
479 template <typename Fn> 479 template <typename Fn>
480 static void map(SkTDArray<uint8_t>* bytes, Fn&& fn) { 480 static void map(SkTDArray<uint8_t>* bytes, Fn&& fn) {
481 for (uint8_t* ptr = bytes->begin(); ptr < bytes->end(); ) { 481 auto end = bytes->end();
482 for (uint8_t* ptr = bytes->begin(); ptr < end; ) {
482 auto op = (Op*)ptr; 483 auto op = (Op*)ptr;
483 fn(op); 484 fn(op);
484 ptr += op->skip; 485 ptr += op->skip;
485 } 486 }
486 } 487 }
487 488
488 void SkLiteDL:: save() { push <Save>(&fBytes, 0); } 489 void SkLiteDL:: save() { push <Save>(&fBytes, 0); }
489 void SkLiteDL::restore() { push<Restore>(&fBytes, 0); } 490 void SkLiteDL::restore() { push<Restore>(&fBytes, 0); }
490 void SkLiteDL::saveLayer(const SkRect* bounds, const SkPaint* paint, 491 void SkLiteDL::saveLayer(const SkRect* bounds, const SkPaint* paint,
491 const SkImageFilter* backdrop, SkCanvas::SaveLayerFlags flags) { 492 const SkImageFilter* backdrop, SkCanvas::SaveLayerFlags flags) {
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 } 714 }
714 715
715 void SkLiteDL::PurgeFreelist() { 716 void SkLiteDL::PurgeFreelist() {
716 SkAutoMutexAcquire lock(gFreeStackLock); 717 SkAutoMutexAcquire lock(gFreeStackLock);
717 while (gFreeStack) { 718 while (gFreeStack) {
718 SkLiteDL* top = gFreeStack; 719 SkLiteDL* top = gFreeStack;
719 gFreeStack = gFreeStack->fNext; 720 gFreeStack = gFreeStack->fNext;
720 delete top; // Calling unref() here would just put it back on the list ! 721 delete top; // Calling unref() here would just put it back on the list !
721 } 722 }
722 } 723 }
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