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 14 matching lines...) Expand all Loading... |
25 const SkRect& srcRect, const SkRect& dstRect, | 25 const SkRect& srcRect, const SkRect& dstRect, |
26 SkFilterQuality filterQuality) | 26 SkFilterQuality filterQuality) |
27 : INHERITED(0, 0) | 27 : INHERITED(0, 0) |
28 , fBitmap(bitmap) | 28 , fBitmap(bitmap) |
29 , fSrcRect(srcRect) | 29 , fSrcRect(srcRect) |
30 , fDstRect(dstRect) | 30 , fDstRect(dstRect) |
31 , fFilterQuality(filterQuality) { | 31 , fFilterQuality(filterQuality) { |
32 } | 32 } |
33 | 33 |
34 SkFlattenable* SkBitmapSource::CreateProc(SkReadBuffer& buffer) { | 34 SkFlattenable* SkBitmapSource::CreateProc(SkReadBuffer& buffer) { |
| 35 SkFilterQuality filterQuality; |
| 36 if (buffer.isVersionLT(SkReadBuffer::kBitmapourceFilterQuality_Version)) { |
| 37 filterQuality = kHigh_SkFilterQuality; |
| 38 } else { |
| 39 filterQuality = (SkFilterQuality)buffer.readInt(); |
| 40 } |
35 SkRect src, dst; | 41 SkRect src, dst; |
36 buffer.readRect(&src); | 42 buffer.readRect(&src); |
37 buffer.readRect(&dst); | 43 buffer.readRect(&dst); |
38 SkBitmap bitmap; | 44 SkBitmap bitmap; |
39 if (!buffer.readBitmap(&bitmap)) { | 45 if (!buffer.readBitmap(&bitmap)) { |
40 return NULL; | 46 return NULL; |
41 } | 47 } |
42 return SkBitmapSource::Create(bitmap, src, dst); | 48 return SkBitmapSource::Create(bitmap, src, dst, filterQuality); |
43 } | 49 } |
44 | 50 |
45 void SkBitmapSource::flatten(SkWriteBuffer& buffer) const { | 51 void SkBitmapSource::flatten(SkWriteBuffer& buffer) const { |
| 52 buffer.writeInt(fFilterQuality); |
46 buffer.writeRect(fSrcRect); | 53 buffer.writeRect(fSrcRect); |
47 buffer.writeRect(fDstRect); | 54 buffer.writeRect(fDstRect); |
48 buffer.writeBitmap(fBitmap); | 55 buffer.writeBitmap(fBitmap); |
49 } | 56 } |
50 | 57 |
51 bool SkBitmapSource::onFilterImage(Proxy* proxy, const SkBitmap&, const Context&
ctx, | 58 bool SkBitmapSource::onFilterImage(Proxy* proxy, const SkBitmap&, const Context&
ctx, |
52 SkBitmap* result, SkIPoint* offset) const { | 59 SkBitmap* result, SkIPoint* offset) const { |
53 SkRect bounds, dstRect; | 60 SkRect bounds, dstRect; |
54 fBitmap.getBounds(&bounds); | 61 fBitmap.getBounds(&bounds); |
55 ctx.ctm().mapRect(&dstRect, fDstRect); | 62 ctx.ctm().mapRect(&dstRect, fDstRect); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 void SkBitmapSource::toString(SkString* str) const { | 101 void SkBitmapSource::toString(SkString* str) const { |
95 str->appendf("SkBitmapSource: ("); | 102 str->appendf("SkBitmapSource: ("); |
96 str->appendf("src: (%f,%f,%f,%f) dst: (%f,%f,%f,%f) ", | 103 str->appendf("src: (%f,%f,%f,%f) dst: (%f,%f,%f,%f) ", |
97 fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBotto
m, | 104 fSrcRect.fLeft, fSrcRect.fTop, fSrcRect.fRight, fSrcRect.fBotto
m, |
98 fDstRect.fLeft, fDstRect.fTop, fDstRect.fRight, fDstRect.fBotto
m); | 105 fDstRect.fLeft, fDstRect.fTop, fDstRect.fRight, fDstRect.fBotto
m); |
99 str->appendf("bitmap: (%d,%d)", | 106 str->appendf("bitmap: (%d,%d)", |
100 fBitmap.width(), fBitmap.height()); | 107 fBitmap.width(), fBitmap.height()); |
101 str->append(")"); | 108 str->append(")"); |
102 } | 109 } |
103 #endif | 110 #endif |
OLD | NEW |