| 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 "SkImagePriv.h" | 10 #include "SkImagePriv.h" |
| 11 #include "SkImage_Base.h" | 11 #include "SkImage_Base.h" |
| 12 #include "SkReadPixelsRec.h" | 12 #include "SkReadPixelsRec.h" |
| 13 #include "SkString.h" |
| 13 #include "SkSurface.h" | 14 #include "SkSurface.h" |
| 14 | 15 |
| 15 uint32_t SkImage::NextUniqueID() { | 16 uint32_t SkImage::NextUniqueID() { |
| 16 static int32_t gUniqueID; | 17 static int32_t gUniqueID; |
| 17 | 18 |
| 18 // never return 0; | 19 // never return 0; |
| 19 uint32_t id; | 20 uint32_t id; |
| 20 do { | 21 do { |
| 21 id = sk_atomic_inc(&gUniqueID) + 1; | 22 id = sk_atomic_inc(&gUniqueID) + 1; |
| 22 } while (0 == id); | 23 } while (0 == id); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 return NULL; | 72 return NULL; |
| 72 } | 73 } |
| 73 | 74 |
| 74 SkSurface* SkImage::newSurface(const SkImageInfo& info, const SkSurfaceProps* pr
ops) const { | 75 SkSurface* SkImage::newSurface(const SkImageInfo& info, const SkSurfaceProps* pr
ops) const { |
| 75 if (NULL == props) { | 76 if (NULL == props) { |
| 76 props = &as_IB(this)->props(); | 77 props = &as_IB(this)->props(); |
| 77 } | 78 } |
| 78 return as_IB(this)->onNewSurface(info, *props); | 79 return as_IB(this)->onNewSurface(info, *props); |
| 79 } | 80 } |
| 80 | 81 |
| 82 const char* SkImage::toString(SkString* str) const { |
| 83 str->appendf("image: (id:%d (%d, %d) %s)", this->uniqueID(), this->width(),
this->height(), |
| 84 this->isOpaque() ? "opaque" : ""); |
| 85 return str->c_str(); |
| 86 } |
| 87 |
| 81 /////////////////////////////////////////////////////////////////////////////// | 88 /////////////////////////////////////////////////////////////////////////////// |
| 82 | 89 |
| 83 static bool raster_canvas_supports(const SkImageInfo& info) { | 90 static bool raster_canvas_supports(const SkImageInfo& info) { |
| 84 switch (info.colorType()) { | 91 switch (info.colorType()) { |
| 85 case kN32_SkColorType: | 92 case kN32_SkColorType: |
| 86 return kUnpremul_SkAlphaType != info.alphaType(); | 93 return kUnpremul_SkAlphaType != info.alphaType(); |
| 87 case kRGB_565_SkColorType: | 94 case kRGB_565_SkColorType: |
| 88 return true; | 95 return true; |
| 89 case kAlpha_8_SkColorType: | 96 case kAlpha_8_SkColorType: |
| 90 return true; | 97 return true; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 103 SkBitmap bm; | 110 SkBitmap bm; |
| 104 bm.installPixels(dstInfo, dstPixels, dstRowBytes); | 111 bm.installPixels(dstInfo, dstPixels, dstRowBytes); |
| 105 SkCanvas canvas(bm); | 112 SkCanvas canvas(bm); |
| 106 | 113 |
| 107 SkPaint paint; | 114 SkPaint paint; |
| 108 paint.setXfermodeMode(SkXfermode::kSrc_Mode); | 115 paint.setXfermodeMode(SkXfermode::kSrc_Mode); |
| 109 canvas.drawImage(this, -SkIntToScalar(srcX), -SkIntToScalar(srcY), &paint); | 116 canvas.drawImage(this, -SkIntToScalar(srcX), -SkIntToScalar(srcY), &paint); |
| 110 | 117 |
| 111 return true; | 118 return true; |
| 112 } | 119 } |
| OLD | NEW |