| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 The Android Open Source Project | 2 * Copyright 2012 The Android Open Source Project |
| 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 "SkMergeImageFilter.h" | 8 #include "SkMergeImageFilter.h" |
| 9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkDevice.h" | 10 #include "SkDevice.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 const int x0 = bounds.left(); | 70 const int x0 = bounds.left(); |
| 71 const int y0 = bounds.top(); | 71 const int y0 = bounds.top(); |
| 72 | 72 |
| 73 SkAutoTUnref<SkBaseDevice> dst(proxy->createDevice(bounds.width(), bounds.he
ight())); | 73 SkAutoTUnref<SkBaseDevice> dst(proxy->createDevice(bounds.width(), bounds.he
ight())); |
| 74 if (NULL == dst) { | 74 if (NULL == dst) { |
| 75 return false; | 75 return false; |
| 76 } | 76 } |
| 77 SkCanvas canvas(dst); | 77 SkCanvas canvas(dst); |
| 78 SkPaint paint; | 78 SkPaint paint; |
| 79 | 79 |
| 80 bool didProduceResult = false; |
| 80 int inputCount = countInputs(); | 81 int inputCount = countInputs(); |
| 81 for (int i = 0; i < inputCount; ++i) { | 82 for (int i = 0; i < inputCount; ++i) { |
| 82 SkBitmap tmp; | 83 SkBitmap tmp; |
| 83 const SkBitmap* srcPtr; | 84 const SkBitmap* srcPtr; |
| 84 SkIPoint pos = SkIPoint::Make(0, 0); | 85 SkIPoint pos = SkIPoint::Make(0, 0); |
| 85 SkImageFilter* filter = getInput(i); | 86 SkImageFilter* filter = getInput(i); |
| 86 if (filter) { | 87 if (filter) { |
| 87 if (!filter->filterImage(proxy, src, ctx, &tmp, &pos)) { | 88 if (!filter->filterImage(proxy, src, ctx, &tmp, &pos)) { |
| 88 return false; | 89 continue; |
| 89 } | 90 } |
| 90 srcPtr = &tmp; | 91 srcPtr = &tmp; |
| 91 } else { | 92 } else { |
| 92 srcPtr = &src; | 93 srcPtr = &src; |
| 93 } | 94 } |
| 94 | 95 |
| 95 if (fModes) { | 96 if (fModes) { |
| 96 paint.setXfermodeMode((SkXfermode::Mode)fModes[i]); | 97 paint.setXfermodeMode((SkXfermode::Mode)fModes[i]); |
| 97 } else { | 98 } else { |
| 98 paint.setXfermode(NULL); | 99 paint.setXfermode(NULL); |
| 99 } | 100 } |
| 100 canvas.drawSprite(*srcPtr, pos.x() - x0, pos.y() - y0, &paint); | 101 canvas.drawSprite(*srcPtr, pos.x() - x0, pos.y() - y0, &paint); |
| 102 didProduceResult = true; |
| 101 } | 103 } |
| 102 | 104 |
| 105 if (!didProduceResult) |
| 106 return false; |
| 107 |
| 103 offset->fX = bounds.left(); | 108 offset->fX = bounds.left(); |
| 104 offset->fY = bounds.top(); | 109 offset->fY = bounds.top(); |
| 105 *result = dst->accessBitmap(false); | 110 *result = dst->accessBitmap(false); |
| 106 return true; | 111 return true; |
| 107 } | 112 } |
| 108 | 113 |
| 109 SkFlattenable* SkMergeImageFilter::CreateProc(SkReadBuffer& buffer) { | 114 SkFlattenable* SkMergeImageFilter::CreateProc(SkReadBuffer& buffer) { |
| 110 Common common; | 115 Common common; |
| 111 if (!common.unflatten(buffer, -1)) { | 116 if (!common.unflatten(buffer, -1)) { |
| 112 return NULL; | 117 return NULL; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 for (int i = 0; i < this->countInputs(); ++i) { | 152 for (int i = 0; i < this->countInputs(); ++i) { |
| 148 SkImageFilter* filter = this->getInput(i); | 153 SkImageFilter* filter = this->getInput(i); |
| 149 str->appendf("%d: (", i); | 154 str->appendf("%d: (", i); |
| 150 filter->toString(str); | 155 filter->toString(str); |
| 151 str->appendf(")"); | 156 str->appendf(")"); |
| 152 } | 157 } |
| 153 | 158 |
| 154 str->append(")"); | 159 str->append(")"); |
| 155 } | 160 } |
| 156 #endif | 161 #endif |
| OLD | NEW |