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

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

Issue 173893002: use colortype instead of config (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/SkBitmapScaler.cpp ('k') | src/core/SkBlitter.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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 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 #include "SkBitmap.h" 8 #include "SkBitmap.h"
9 #include "SkRegion.h" 9 #include "SkRegion.h"
10 10
11 bool SkBitmap::scrollRect(const SkIRect* subset, int dx, int dy, 11 bool SkBitmap::scrollRect(const SkIRect* subset, int dx, int dy,
12 SkRegion* inval) const 12 SkRegion* inval) const
13 { 13 {
14 if (this->isImmutable()) { 14 if (this->isImmutable() || kUnknown_SkColorType == this->colorType()) {
15 return false; 15 return false;
16 } 16 }
17 17
18 if (NULL != subset) { 18 if (NULL != subset) {
19 SkBitmap tmp; 19 SkBitmap tmp;
20 20
21 return this->extractSubset(&tmp, *subset) && 21 return this->extractSubset(&tmp, *subset) &&
22 // now call again with no rectangle 22 // now call again with no rectangle
23 tmp.scrollRect(NULL, dx, dy, inval); 23 tmp.scrollRect(NULL, dx, dy, inval);
24 } 24 }
25 25
26 int shift; 26 int shift = this->bytesPerPixel() >> 1;
27
28 switch (this->config()) {
29 case kIndex8_Config:
30 case kA8_Config:
31 shift = 0;
32 break;
33 case kARGB_4444_Config:
34 case kRGB_565_Config:
35 shift = 1;
36 break;
37 case kARGB_8888_Config:
38 shift = 2;
39 break;
40 default:
41 // can't scroll this config
42 return false;
43 }
44
45 int width = this->width(); 27 int width = this->width();
46 int height = this->height(); 28 int height = this->height();
47 29
48 // check if there's nothing to do 30 // check if there's nothing to do
49 if ((dx | dy) == 0 || width <= 0 || height <= 0) { 31 if ((dx | dy) == 0 || width <= 0 || height <= 0) {
50 if (NULL != inval) { 32 if (NULL != inval) {
51 inval->setEmpty(); 33 inval->setEmpty();
52 } 34 }
53 return true; 35 return true;
54 } 36 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 width <<= shift; // now width is the number of bytes to move per line 96 width <<= shift; // now width is the number of bytes to move per line
115 while (--height >= 0) { 97 while (--height >= 0) {
116 memmove(dst, src, width); 98 memmove(dst, src, width);
117 dst += rowBytes; 99 dst += rowBytes;
118 src += rowBytes; 100 src += rowBytes;
119 } 101 }
120 102
121 this->notifyPixelsChanged(); 103 this->notifyPixelsChanged();
122 return true; 104 return true;
123 } 105 }
OLDNEW
« no previous file with comments | « src/core/SkBitmapScaler.cpp ('k') | src/core/SkBlitter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698