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

Side by Side Diff: include/core/SkPixmap.h

Issue 1826233002: Add rowBytesAsPixels and shiftPerPixel to SkPixmap (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add cast Created 4 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 | « 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 * Copyright 2015 Google Inc. 2 * Copyright 2015 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 #ifndef SkPixmap_DEFINED 8 #ifndef SkPixmap_DEFINED
9 #define SkPixmap_DEFINED 9 #define SkPixmap_DEFINED
10 10
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 SkColorTable* ctable() const { return fCTable; } 64 SkColorTable* ctable() const { return fCTable; }
65 65
66 int width() const { return fInfo.width(); } 66 int width() const { return fInfo.width(); }
67 int height() const { return fInfo.height(); } 67 int height() const { return fInfo.height(); }
68 SkColorType colorType() const { return fInfo.colorType(); } 68 SkColorType colorType() const { return fInfo.colorType(); }
69 SkAlphaType alphaType() const { return fInfo.alphaType(); } 69 SkAlphaType alphaType() const { return fInfo.alphaType(); }
70 bool isOpaque() const { return fInfo.isOpaque(); } 70 bool isOpaque() const { return fInfo.isOpaque(); }
71 71
72 SkIRect bounds() const { return SkIRect::MakeWH(this->width(), this->height( )); } 72 SkIRect bounds() const { return SkIRect::MakeWH(this->width(), this->height( )); }
73 73
74 /**
75 * Return the rowbytes expressed as a number of pixels (like width and heig ht).
76 */
77 int rowBytesAsPixels() const { return int(fRowBytes >> this->shiftPerPixel() ); }
78
79 /**
80 * Return the shift amount per pixel (i.e. 0 for 1-byte per pixel, 1 for 2- bytes per pixel
81 * colortypes, 2 for 4-bytes per pixel colortypes). Return 0 for kUnknown_S kColorType.
82 */
83 int shiftPerPixel() const { return fInfo.bytesPerPixel() >> 1; }
84
74 uint64_t getSize64() const { return sk_64_mul(fInfo.height(), fRowBytes); } 85 uint64_t getSize64() const { return sk_64_mul(fInfo.height(), fRowBytes); }
75 uint64_t getSafeSize64() const { return fInfo.getSafeSize64(fRowBytes); } 86 uint64_t getSafeSize64() const { return fInfo.getSafeSize64(fRowBytes); }
76 size_t getSafeSize() const { return fInfo.getSafeSize(fRowBytes); } 87 size_t getSafeSize() const { return fInfo.getSafeSize(fRowBytes); }
77 88
78 const void* addr(int x, int y) const { 89 const void* addr(int x, int y) const {
79 return (const char*)fPixels + fInfo.computeOffset(x, y, fRowBytes); 90 return (const char*)fPixels + fInfo.computeOffset(x, y, fRowBytes);
80 } 91 }
81 const uint8_t* addr8() const { 92 const uint8_t* addr8() const {
82 SkASSERT(1 == SkColorTypeBytesPerPixel(fInfo.colorType())); 93 SkASSERT(1 == SkColorTypeBytesPerPixel(fInfo.colorType()));
83 return reinterpret_cast<const uint8_t*>(fPixels); 94 return reinterpret_cast<const uint8_t*>(fPixels);
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 private: 240 private:
230 void (*fUnlockProc)(void*); 241 void (*fUnlockProc)(void*);
231 void* fUnlockContext; 242 void* fUnlockContext;
232 SkPixmap fPixmap; 243 SkPixmap fPixmap;
233 bool fIsLocked; 244 bool fIsLocked;
234 245
235 friend class SkBitmap; 246 friend class SkBitmap;
236 }; 247 };
237 248
238 #endif 249 #endif
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