OLD | NEW |
---|---|
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 #include "SkConfig8888.h" | 8 #include "SkConfig8888.h" |
9 #include "SkPixmap.h" | 9 #include "SkPixmap.h" |
10 | 10 |
11 void SkAutoPixmapUnlock::reset(const SkPixmap& pm, void (*unlock)(void*), void* ctx) { | 11 void SkAutoPixmapUnlock::reset(const SkPixmap& pm, void (*unlock)(void*), void* ctx) { |
12 SkASSERT(pm.addr() != NULL); | 12 SkASSERT(pm.addr() != NULL); |
13 | 13 |
14 this->unlock(); | 14 this->unlock(); |
15 fPixmap = pm; | 15 fPixmap = pm; |
16 fUnlockProc = unlock; | 16 fUnlockProc = unlock; |
17 fUnlockContext = ctx; | 17 fUnlockContext = ctx; |
18 fIsLocked = true; | 18 fIsLocked = true; |
19 } | 19 } |
20 | 20 |
21 //////////////////////////////////////////////////////////////////////////////// ///////////////// | 21 //////////////////////////////////////////////////////////////////////////////// ///////////////// |
22 | 22 |
23 void SkPixmap::reset() { | |
24 fPixels = NULL; | |
25 fCTable = NULL; | |
26 fRowBytes = 0; | |
27 fInfo = SkImageInfo::MakeUnknown(); | |
28 } | |
29 | |
30 void SkPixmap::reset(const SkImageInfo& info, const void* addr, size_t rowBytes, SkColorTable* ct) { | |
31 if (addr) { | |
scroggo
2015/05/26 18:30:31
It seems like if addr is NULL, the rest of these a
reed1
2015/05/26 18:45:24
Yea, still "evolving" what I think we should enfor
| |
32 SkASSERT(info.validRowBytes(rowBytes)); | |
33 } | |
34 fPixels = addr; | |
35 fCTable = ct; | |
36 fRowBytes = rowBytes; | |
37 fInfo = info; | |
38 } | |
39 | |
23 bool SkPixmap::readPixels(const SkImageInfo& requestedDstInfo, void* dstPixels, size_t dstRB, | 40 bool SkPixmap::readPixels(const SkImageInfo& requestedDstInfo, void* dstPixels, size_t dstRB, |
24 int x, int y) const { | 41 int x, int y) const { |
25 if (kUnknown_SkColorType == requestedDstInfo.colorType()) { | 42 if (kUnknown_SkColorType == requestedDstInfo.colorType()) { |
26 return false; | 43 return false; |
27 } | 44 } |
28 if (NULL == dstPixels || dstRB < requestedDstInfo.minRowBytes()) { | 45 if (NULL == dstPixels || dstRB < requestedDstInfo.minRowBytes()) { |
29 return false; | 46 return false; |
30 } | 47 } |
31 if (0 == requestedDstInfo.width() || 0 == requestedDstInfo.height()) { | 48 if (0 == requestedDstInfo.width() || 0 == requestedDstInfo.height()) { |
32 return false; | 49 return false; |
(...skipping 15 matching lines...) Expand all Loading... | |
48 y = 0; | 65 y = 0; |
49 } | 66 } |
50 // here x,y are either 0 or negative | 67 // here x,y are either 0 or negative |
51 dstPixels = ((char*)dstPixels - y * dstRB - x * dstInfo.bytesPerPixel()); | 68 dstPixels = ((char*)dstPixels - y * dstRB - x * dstInfo.bytesPerPixel()); |
52 | 69 |
53 const SkImageInfo srcInfo = this->info().makeWH(dstInfo.width(), dstInfo.hei ght()); | 70 const SkImageInfo srcInfo = this->info().makeWH(dstInfo.width(), dstInfo.hei ght()); |
54 const void* srcPixels = this->addr(srcR.x(), srcR.y()); | 71 const void* srcPixels = this->addr(srcR.x(), srcR.y()); |
55 return SkPixelInfo::CopyPixels(dstInfo, dstPixels, dstRB, | 72 return SkPixelInfo::CopyPixels(dstInfo, dstPixels, dstRB, |
56 srcInfo, srcPixels, this->rowBytes(), this->c table()); | 73 srcInfo, srcPixels, this->rowBytes(), this->c table()); |
57 } | 74 } |
OLD | NEW |