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

Side by Side Diff: src/utils/SkBitmapChecksummer.cpp

Issue 12629003: Fix a warning in bitmap checksummer. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 9 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 | « 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 /* 2 /*
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkBitmapChecksummer.h" 10 #include "SkBitmapChecksummer.h"
11 #include "SkBitmapTransformer.h" 11 #include "SkBitmapTransformer.h"
12 #include "SkCityHash.h" 12 #include "SkCityHash.h"
13 #include "SkEndian.h" 13 #include "SkEndian.h"
14 14
15 /** 15 /**
16 * Write an integer value into a bytebuffer in little-endian order. 16 * Write an integer value into a bytebuffer in little-endian order.
17 */ 17 */
18 static void write_int_to_buffer(int val, char* buf) { 18 static void write_int_to_buffer(int val, char* buf) {
19 val = SkEndian_SwapLE32(val); 19 val = SkEndian_SwapLE32(val);
20 for (int byte=0; byte<4; byte++) { 20 for (int byte=0; byte<4; byte++) {
21 *buf++ = (char)(val & 0xff); 21 *buf++ = (char)(val & 0xff);
22 val = val >> 8; 22 val = val >> 8;
23 } 23 }
24 } 24 }
25 25
26 /*static*/ uint64_t SkBitmapChecksummer::Compute64Internal( 26 /*static*/ uint64_t SkBitmapChecksummer::Compute64Internal(
27 const SkBitmap& bitmap, const SkBitmapTransformer& transformer) { 27 const SkBitmap& bitmap, const SkBitmapTransformer& transformer) {
28 int pixelBufferSize = transformer.bytesNeededTotal(); 28 size_t pixelBufferSize = transformer.bytesNeededTotal();
29 int totalBufferSize = pixelBufferSize + 8; // leave room for x/y dimensions 29 size_t totalBufferSize = pixelBufferSize + 8; // leave room for x/y dimensio ns
30 30
31 SkAutoMalloc bufferManager(totalBufferSize); 31 SkAutoMalloc bufferManager(totalBufferSize);
32 char *bufferStart = static_cast<char *>(bufferManager.get()); 32 char *bufferStart = static_cast<char *>(bufferManager.get());
33 char *bufPtr = bufferStart; 33 char *bufPtr = bufferStart;
34 // start with the x/y dimensions 34 // start with the x/y dimensions
35 write_int_to_buffer(bitmap.width(), bufPtr); 35 write_int_to_buffer(bitmap.width(), bufPtr);
36 bufPtr += 4; 36 bufPtr += 4;
37 write_int_to_buffer(bitmap.height(), bufPtr); 37 write_int_to_buffer(bitmap.height(), bufPtr);
38 bufPtr += 4; 38 bufPtr += 4;
39 39
(...skipping 20 matching lines...) Expand all
60 SkBitmap copyBitmap; 60 SkBitmap copyBitmap;
61 bitmap.copyTo(&copyBitmap, SkBitmap::kARGB_8888_Config); 61 bitmap.copyTo(&copyBitmap, SkBitmap::kARGB_8888_Config);
62 const SkBitmapTransformer copyTransformer = 62 const SkBitmapTransformer copyTransformer =
63 SkBitmapTransformer(copyBitmap, kPixelFormat); 63 SkBitmapTransformer(copyBitmap, kPixelFormat);
64 if (copyTransformer.isValid(true)) { 64 if (copyTransformer.isValid(true)) {
65 return Compute64Internal(copyBitmap, copyTransformer); 65 return Compute64Internal(copyBitmap, copyTransformer);
66 } else { 66 } else {
67 return 0; 67 return 0;
68 } 68 }
69 } 69 }
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