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 "SkBitmapSource.h" | 8 #include "SkBitmapSource.h" |
9 #include "SkDevice.h" | 9 #include "SkDevice.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 fBitmap(bitmap), | 24 fBitmap(bitmap), |
25 fSrcRect(srcRect), | 25 fSrcRect(srcRect), |
26 fDstRect(dstRect) { | 26 fDstRect(dstRect) { |
27 } | 27 } |
28 | 28 |
29 SkBitmapSource::SkBitmapSource(SkFlattenableReadBuffer& buffer) | 29 SkBitmapSource::SkBitmapSource(SkFlattenableReadBuffer& buffer) |
30 : INHERITED(0, buffer) { | 30 : INHERITED(0, buffer) { |
31 fBitmap.unflatten(buffer); | 31 fBitmap.unflatten(buffer); |
32 buffer.readRect(&fSrcRect); | 32 buffer.readRect(&fSrcRect); |
33 buffer.readRect(&fDstRect); | 33 buffer.readRect(&fDstRect); |
34 buffer.validate(SkIsValidRect(fSrcRect) && SkIsValidRect(fDstRect)); | 34 buffer.validate(buffer.isValid() && SkIsValidRect(fSrcRect) && SkIsValidRect
(fDstRect)); |
35 } | 35 } |
36 | 36 |
37 void SkBitmapSource::flatten(SkFlattenableWriteBuffer& buffer) const { | 37 void SkBitmapSource::flatten(SkFlattenableWriteBuffer& buffer) const { |
38 this->INHERITED::flatten(buffer); | 38 this->INHERITED::flatten(buffer); |
39 fBitmap.flatten(buffer); | 39 fBitmap.flatten(buffer); |
40 buffer.writeRect(fSrcRect); | 40 buffer.writeRect(fSrcRect); |
41 buffer.writeRect(fDstRect); | 41 buffer.writeRect(fDstRect); |
42 } | 42 } |
43 | 43 |
44 bool SkBitmapSource::onFilterImage(Proxy* proxy, const SkBitmap&, const SkMatrix
& matrix, | 44 bool SkBitmapSource::onFilterImage(Proxy* proxy, const SkBitmap&, const SkMatrix
& matrix, |
(...skipping 25 matching lines...) Expand all Loading... |
70 paint.setFilterLevel( | 70 paint.setFilterLevel( |
71 fSrcRect.width() == dstRect.width() && fSrcRect.height() == dstRect.heig
ht() ? | 71 fSrcRect.width() == dstRect.width() && fSrcRect.height() == dstRect.heig
ht() ? |
72 SkPaint::kNone_FilterLevel : SkPaint::kMedium_FilterLevel); | 72 SkPaint::kNone_FilterLevel : SkPaint::kMedium_FilterLevel); |
73 canvas.drawBitmapRectToRect(fBitmap, &fSrcRect, dstRect, &paint); | 73 canvas.drawBitmapRectToRect(fBitmap, &fSrcRect, dstRect, &paint); |
74 | 74 |
75 *result = device.get()->accessBitmap(false); | 75 *result = device.get()->accessBitmap(false); |
76 offset->fX += dstIRect.fLeft; | 76 offset->fX += dstIRect.fLeft; |
77 offset->fY += dstIRect.fTop; | 77 offset->fY += dstIRect.fTop; |
78 return true; | 78 return true; |
79 } | 79 } |
OLD | NEW |