OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkImageGenerator.h" |
10 #include "SkImagePriv.h" | 11 #include "SkImagePriv.h" |
11 #include "SkImage_Base.h" | 12 #include "SkImage_Base.h" |
12 #include "SkReadPixelsRec.h" | 13 #include "SkReadPixelsRec.h" |
13 #include "SkString.h" | 14 #include "SkString.h" |
14 #include "SkSurface.h" | 15 #include "SkSurface.h" |
15 | 16 |
16 uint32_t SkImage::NextUniqueID() { | 17 uint32_t SkImage::NextUniqueID() { |
17 static int32_t gUniqueID; | 18 static int32_t gUniqueID; |
18 | 19 |
19 // never return 0; | 20 // never return 0; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 } | 66 } |
66 | 67 |
67 SkData* SkImage::encode(SkImageEncoder::Type type, int quality) const { | 68 SkData* SkImage::encode(SkImageEncoder::Type type, int quality) const { |
68 SkBitmap bm; | 69 SkBitmap bm; |
69 if (as_IB(this)->getROPixels(&bm)) { | 70 if (as_IB(this)->getROPixels(&bm)) { |
70 return SkImageEncoder::EncodeData(bm, type, quality); | 71 return SkImageEncoder::EncodeData(bm, type, quality); |
71 } | 72 } |
72 return NULL; | 73 return NULL; |
73 } | 74 } |
74 | 75 |
| 76 SkImage* SkImage::NewFromData(SkData* data) { |
| 77 if (NULL == data) { |
| 78 return NULL; |
| 79 } |
| 80 SkImageGenerator* generator = SkImageGenerator::NewFromData(data); |
| 81 return generator ? SkImage::NewFromGenerator(generator) : NULL; |
| 82 } |
| 83 |
75 SkSurface* SkImage::newSurface(const SkImageInfo& info, const SkSurfaceProps* pr
ops) const { | 84 SkSurface* SkImage::newSurface(const SkImageInfo& info, const SkSurfaceProps* pr
ops) const { |
76 if (NULL == props) { | 85 if (NULL == props) { |
77 props = &as_IB(this)->props(); | 86 props = &as_IB(this)->props(); |
78 } | 87 } |
79 return as_IB(this)->onNewSurface(info, *props); | 88 return as_IB(this)->onNewSurface(info, *props); |
80 } | 89 } |
81 | 90 |
82 const char* SkImage::toString(SkString* str) const { | 91 const char* SkImage::toString(SkString* str) const { |
83 str->appendf("image: (id:%d (%d, %d) %s)", this->uniqueID(), this->width(),
this->height(), | 92 str->appendf("image: (id:%d (%d, %d) %s)", this->uniqueID(), this->width(),
this->height(), |
84 this->isOpaque() ? "opaque" : ""); | 93 this->isOpaque() ? "opaque" : ""); |
(...skipping 25 matching lines...) Expand all Loading... |
110 SkBitmap bm; | 119 SkBitmap bm; |
111 bm.installPixels(dstInfo, dstPixels, dstRowBytes); | 120 bm.installPixels(dstInfo, dstPixels, dstRowBytes); |
112 SkCanvas canvas(bm); | 121 SkCanvas canvas(bm); |
113 | 122 |
114 SkPaint paint; | 123 SkPaint paint; |
115 paint.setXfermodeMode(SkXfermode::kSrc_Mode); | 124 paint.setXfermodeMode(SkXfermode::kSrc_Mode); |
116 canvas.drawImage(this, -SkIntToScalar(srcX), -SkIntToScalar(srcY), &paint); | 125 canvas.drawImage(this, -SkIntToScalar(srcX), -SkIntToScalar(srcY), &paint); |
117 | 126 |
118 return true; | 127 return true; |
119 } | 128 } |
OLD | NEW |