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

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

Issue 1306443004: Use static_assert instead of SK_COMPILE_ASSERT. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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 | « src/core/SkPictureRecord.cpp ('k') | src/core/SkStroke.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 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 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 "SkChecksum.h" 8 #include "SkChecksum.h"
9 #include "SkMessageBus.h" 9 #include "SkMessageBus.h"
10 #include "SkMipMap.h" 10 #include "SkMipMap.h"
(...skipping 18 matching lines...) Expand all
29 29
30 void SkResourceCache::Key::init(void* nameSpace, uint64_t sharedID, size_t lengt h) { 30 void SkResourceCache::Key::init(void* nameSpace, uint64_t sharedID, size_t lengt h) {
31 SkASSERT(SkAlign4(length) == length); 31 SkASSERT(SkAlign4(length) == length);
32 32
33 // fCount32 and fHash are not hashed 33 // fCount32 and fHash are not hashed
34 static const int kUnhashedLocal32s = 2; // fCache32 + fHash 34 static const int kUnhashedLocal32s = 2; // fCache32 + fHash
35 static const int kSharedIDLocal32s = 2; // fSharedID_lo + fSharedID_hi 35 static const int kSharedIDLocal32s = 2; // fSharedID_lo + fSharedID_hi
36 static const int kHashedLocal32s = kSharedIDLocal32s + (sizeof(fNamespace) > > 2); 36 static const int kHashedLocal32s = kSharedIDLocal32s + (sizeof(fNamespace) > > 2);
37 static const int kLocal32s = kUnhashedLocal32s + kHashedLocal32s; 37 static const int kLocal32s = kUnhashedLocal32s + kHashedLocal32s;
38 38
39 SK_COMPILE_ASSERT(sizeof(Key) == (kLocal32s << 2), unaccounted_key_locals); 39 static_assert(sizeof(Key) == (kLocal32s << 2), "unaccounted_key_locals");
40 SK_COMPILE_ASSERT(sizeof(Key) == offsetof(Key, fNamespace) + sizeof(fNamespa ce), 40 static_assert(sizeof(Key) == offsetof(Key, fNamespace) + sizeof(fNamespace),
41 namespace_field_must_be_last); 41 "namespace_field_must_be_last");
42 42
43 fCount32 = SkToS32(kLocal32s + (length >> 2)); 43 fCount32 = SkToS32(kLocal32s + (length >> 2));
44 fSharedID_lo = (uint32_t)sharedID; 44 fSharedID_lo = (uint32_t)sharedID;
45 fSharedID_hi = (uint32_t)(sharedID >> 32); 45 fSharedID_hi = (uint32_t)(sharedID >> 32);
46 fNamespace = nameSpace; 46 fNamespace = nameSpace;
47 // skip unhashed fields when computing the murmur 47 // skip unhashed fields when computing the murmur
48 fHash = SkChecksum::Murmur3(this->as32() + kUnhashedLocal32s, 48 fHash = SkChecksum::Murmur3(this->as32() + kUnhashedLocal32s,
49 (fCount32 - kUnhashedLocal32s) << 2); 49 (fCount32 - kUnhashedLocal32s) << 2);
50 } 50 }
51 51
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 ///////////// 664 /////////////
665 665
666 static void dump_visitor(const SkResourceCache::Rec& rec, void*) { 666 static void dump_visitor(const SkResourceCache::Rec& rec, void*) {
667 SkDebugf("RC: %12s bytes %9lu discardable %p\n", 667 SkDebugf("RC: %12s bytes %9lu discardable %p\n",
668 rec.getCategory(), rec.bytesUsed(), rec.diagnostic_only_getDiscarda ble()); 668 rec.getCategory(), rec.bytesUsed(), rec.diagnostic_only_getDiscarda ble());
669 } 669 }
670 670
671 void SkResourceCache::TestDumpMemoryStatistics() { 671 void SkResourceCache::TestDumpMemoryStatistics() {
672 VisitAll(dump_visitor, nullptr); 672 VisitAll(dump_visitor, nullptr);
673 } 673 }
OLDNEW
« no previous file with comments | « src/core/SkPictureRecord.cpp ('k') | src/core/SkStroke.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698