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

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

Issue 1153893003: move readPixels from bitmap -> pixmap (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 7 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 | src/core/SkBitmap.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 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 26 matching lines...) Expand all
37 size_t rowBytes() const { return fRowBytes; } 37 size_t rowBytes() const { return fRowBytes; }
38 const void* addr() const { return fPixels; } 38 const void* addr() const { return fPixels; }
39 SkColorTable* ctable() const { return fCTable; } 39 SkColorTable* ctable() const { return fCTable; }
40 40
41 int width() const { return fInfo.width(); } 41 int width() const { return fInfo.width(); }
42 int height() const { return fInfo.height(); } 42 int height() const { return fInfo.height(); }
43 SkColorType colorType() const { return fInfo.colorType(); } 43 SkColorType colorType() const { return fInfo.colorType(); }
44 SkAlphaType alphaType() const { return fInfo.alphaType(); } 44 SkAlphaType alphaType() const { return fInfo.alphaType(); }
45 bool isOpaque() const { return fInfo.isOpaque(); } 45 bool isOpaque() const { return fInfo.isOpaque(); }
46 46
47 int64_t getSafeSize64() const { return fInfo.getSafeSize64(fRowBytes); } 47 uint64_t getSize64() const { return sk_64_mul(fInfo.height(), fRowBytes); }
48 uint64_t getSafeSize64() const { return fInfo.getSafeSize64(fRowBytes); }
48 size_t getSafeSize() const { return fInfo.getSafeSize(fRowBytes); } 49 size_t getSafeSize() const { return fInfo.getSafeSize(fRowBytes); }
49 50
50 const uint32_t* addr32() const { 51 const uint32_t* addr32() const {
51 SkASSERT(4 == SkColorTypeBytesPerPixel(fInfo.colorType())); 52 SkASSERT(4 == SkColorTypeBytesPerPixel(fInfo.colorType()));
52 return reinterpret_cast<const uint32_t*>(fPixels); 53 return reinterpret_cast<const uint32_t*>(fPixels);
53 } 54 }
54 55
55 const uint16_t* addr16() const { 56 const uint16_t* addr16() const {
56 SkASSERT(2 == SkColorTypeBytesPerPixel(fInfo.colorType())); 57 SkASSERT(2 == SkColorTypeBytesPerPixel(fInfo.colorType()));
57 return reinterpret_cast<const uint16_t*>(fPixels); 58 return reinterpret_cast<const uint16_t*>(fPixels);
(...skipping 29 matching lines...) Expand all
87 uint32_t* writable_addr32(int x, int y) const { 88 uint32_t* writable_addr32(int x, int y) const {
88 return const_cast<uint32_t*>(this->addr32(x, y)); 89 return const_cast<uint32_t*>(this->addr32(x, y));
89 } 90 }
90 uint16_t* writable_addr16(int x, int y) const { 91 uint16_t* writable_addr16(int x, int y) const {
91 return const_cast<uint16_t*>(this->addr16(x, y)); 92 return const_cast<uint16_t*>(this->addr16(x, y));
92 } 93 }
93 uint8_t* writable_addr8(int x, int y) const { 94 uint8_t* writable_addr8(int x, int y) const {
94 return const_cast<uint8_t*>(this->addr8(x, y)); 95 return const_cast<uint8_t*>(this->addr8(x, y));
95 } 96 }
96 97
98 // copy methods
99
100 bool readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBy tes,
101 int srcX, int srcY) const;
102 bool readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBy tes) const {
103 return this->readPixels(dstInfo, dstPixels, dstRowBytes, 0, 0);
104 }
105 bool readPixels(const SkPixmap& dst, int srcX, int srcY) const {
106 return this->readPixels(dst.info(), dst.writable_addr(), dst.rowBytes(), srcX, srcY);
107 }
108 bool readPixels(const SkPixmap& dst) const {
109 return this->readPixels(dst.info(), dst.writable_addr(), dst.rowBytes(), 0, 0);
110 }
111
97 private: 112 private:
98 const void* fPixels; 113 const void* fPixels;
99 SkColorTable* fCTable; 114 SkColorTable* fCTable;
100 size_t fRowBytes; 115 size_t fRowBytes;
101 SkImageInfo fInfo; 116 SkImageInfo fInfo;
102 }; 117 };
103 118
104 //////////////////////////////////////////////////////////////////////////////// ///////////// 119 //////////////////////////////////////////////////////////////////////////////// /////////////
105 120
106 class SkAutoPixmapUnlock : ::SkNoncopyable { 121 class SkAutoPixmapUnlock : ::SkNoncopyable {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 private: 158 private:
144 void (*fUnlockProc)(void*); 159 void (*fUnlockProc)(void*);
145 void* fUnlockContext; 160 void* fUnlockContext;
146 SkPixmap fPixmap; 161 SkPixmap fPixmap;
147 bool fIsLocked; 162 bool fIsLocked;
148 163
149 friend class SkBitmap; 164 friend class SkBitmap;
150 }; 165 };
151 166
152 #endif 167 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkBitmap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698