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

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

Issue 147053003: fix (some) 64bit warnings -- size_t -> int (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « src/core/SkMallocPixelRef.cpp ('k') | src/core/SkMetaData.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 2007 The Android Open Source Project 2 * Copyright 2007 The Android Open Source Project
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 "SkMask.h" 8 #include "SkMask.h"
9 9
10 /** returns the product if it is positive and fits in 31 bits. Otherwise this 10 /** returns the product if it is positive and fits in 31 bits. Otherwise this
11 returns 0. 11 returns 0.
12 */ 12 */
13 static int32_t safeMul32(int32_t a, int32_t b) { 13 static int32_t safeMul32(int32_t a, int32_t b) {
14 int64_t size = sk_64_mul(a, b); 14 int64_t size = sk_64_mul(a, b);
15 if (size > 0 && sk_64_isS32(size)) { 15 if (size > 0 && sk_64_isS32(size)) {
16 return sk_64_asS32(size); 16 return sk_64_asS32(size);
17 } 17 }
18 return 0; 18 return 0;
19 } 19 }
20 20
21 size_t SkMask::computeImageSize() const { 21 size_t SkMask::computeImageSize() const {
22 return safeMul32(fBounds.height(), fRowBytes); 22 return safeMul32(fBounds.height(), fRowBytes);
23 } 23 }
24 24
25 size_t SkMask::computeTotalImageSize() const { 25 size_t SkMask::computeTotalImageSize() const {
26 size_t size = this->computeImageSize(); 26 size_t size = this->computeImageSize();
27 if (fFormat == SkMask::k3D_Format) { 27 if (fFormat == SkMask::k3D_Format) {
28 size = safeMul32(size, 3); 28 size = safeMul32(SkToS32(size), 3);
29 } 29 }
30 return size; 30 return size;
31 } 31 }
32 32
33 /** We explicitly use this allocator for SkBimap pixels, so that we can 33 /** We explicitly use this allocator for SkBimap pixels, so that we can
34 freely assign memory allocated by one class to the other. 34 freely assign memory allocated by one class to the other.
35 */ 35 */
36 uint8_t* SkMask::AllocImage(size_t size) { 36 uint8_t* SkMask::AllocImage(size_t size) {
37 return (uint8_t*)sk_malloc_throw(SkAlign4(size)); 37 return (uint8_t*)sk_malloc_throw(SkAlign4(size));
38 } 38 }
(...skipping 25 matching lines...) Expand all
64 void* SkMask::getAddr(int x, int y) const { 64 void* SkMask::getAddr(int x, int y) const {
65 SkASSERT(kBW_Format != fFormat); 65 SkASSERT(kBW_Format != fFormat);
66 SkASSERT(fBounds.contains(x, y)); 66 SkASSERT(fBounds.contains(x, y));
67 SkASSERT(fImage); 67 SkASSERT(fImage);
68 68
69 char* addr = (char*)fImage; 69 char* addr = (char*)fImage;
70 addr += (y - fBounds.fTop) * fRowBytes; 70 addr += (y - fBounds.fTop) * fRowBytes;
71 addr += (x - fBounds.fLeft) << maskFormatToShift(fFormat); 71 addr += (x - fBounds.fLeft) << maskFormatToShift(fFormat);
72 return addr; 72 return addr;
73 } 73 }
OLDNEW
« no previous file with comments | « src/core/SkMallocPixelRef.cpp ('k') | src/core/SkMetaData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698