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

Side by Side Diff: src/core/SkVarAlloc.h

Issue 1061783002: Rearrange SkRecord with small N in mind (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 32-bit fix Created 5 years, 8 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 | « src/core/SkRecord.cpp ('k') | src/core/SkVarAlloc.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
1 #ifndef SkVarAlloc_DEFINED 8 #ifndef SkVarAlloc_DEFINED
2 #define SkVarAlloc_DEFINED 9 #define SkVarAlloc_DEFINED
3 10
4 #include "SkTypes.h" 11 #include "SkTypes.h"
5 12
6 class SkVarAlloc : SkNoncopyable { 13 class SkVarAlloc : SkNoncopyable {
7 public: 14 public:
8 // Smallest block we'll allocate is 2**N bytes. 15 // Smallest block we'll allocate is 2**N bytes.
9 explicit SkVarAlloc(size_t minLgSize); 16 explicit SkVarAlloc(size_t minLgSize);
17 // Same as above, but first uses up to len bytes from storage.
18 SkVarAlloc(size_t minLgSize, char* storage, size_t len);
19
10 ~SkVarAlloc(); 20 ~SkVarAlloc();
11 21
12 // Returns contiguous bytes aligned at least for pointers. You may pass SK_ MALLOC_THROW, etc. 22 // Returns contiguous bytes aligned at least for pointers. You may pass SK_ MALLOC_THROW, etc.
13 char* alloc(size_t bytes, unsigned sk_malloc_flags) { 23 char* alloc(size_t bytes, unsigned sk_malloc_flags) {
14 bytes = SkAlignPtr(bytes); 24 bytes = SkAlignPtr(bytes);
15 25
16 if (bytes > fRemaining) { 26 if (bytes > fRemaining) {
17 this->makeSpace(bytes, sk_malloc_flags); 27 this->makeSpace(bytes, sk_malloc_flags);
18 } 28 }
19 SkASSERT(bytes <= fRemaining); 29 SkASSERT(bytes <= fRemaining);
(...skipping 14 matching lines...) Expand all
34 char* fByte; 44 char* fByte;
35 unsigned fRemaining; 45 unsigned fRemaining;
36 unsigned fLgSize; 46 unsigned fLgSize;
37 47
38 struct Block; 48 struct Block;
39 Block* fBlock; 49 Block* fBlock;
40 }; 50 };
41 SK_COMPILE_ASSERT(sizeof(SkVarAlloc) <= 24, SkVarAllocSize); 51 SK_COMPILE_ASSERT(sizeof(SkVarAlloc) <= 24, SkVarAllocSize);
42 52
43 #endif//SkVarAlloc_DEFINED 53 #endif//SkVarAlloc_DEFINED
OLDNEW
« no previous file with comments | « src/core/SkRecord.cpp ('k') | src/core/SkVarAlloc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698