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" |
11 #include "SkReadBuffer.h" | 11 #include "SkReadBuffer.h" |
12 #include "SkWriteBuffer.h" | 12 #include "SkWriteBuffer.h" |
13 #include "SkValidationUtils.h" | 13 #include "SkValidationUtils.h" |
14 | 14 |
15 SkBitmapSource::SkBitmapSource(const SkBitmap& bitmap) | 15 SkBitmapSource::SkBitmapSource(const SkBitmap& bitmap) |
16 : INHERITED(0, 0) | 16 : INHERITED(0, 0) |
17 , fBitmap(bitmap) | 17 , fBitmap(bitmap) |
18 , fSrcRect(SkRect::MakeWH(SkIntToScalar(bitmap.width()), | 18 , fSrcRect(SkRect::MakeWH(SkIntToScalar(bitmap.width()), |
19 SkIntToScalar(bitmap.height()))) | 19 SkIntToScalar(bitmap.height()))) |
20 , fDstRect(fSrcRect) | 20 , fDstRect(fSrcRect) |
21 {} | 21 {} |
22 | 22 |
23 SkBitmapSource::SkBitmapSource(const SkBitmap& bitmap, const SkRect& srcRect, co
nst SkRect& dstRect) | 23 SkBitmapSource::SkBitmapSource(const SkBitmap& bitmap, const SkRect& srcRect, co
nst SkRect& dstRect) |
24 : INHERITED(0, 0) | 24 : INHERITED(0, 0) |
25 , fBitmap(bitmap) | 25 , fBitmap(bitmap) |
26 , fSrcRect(srcRect) | 26 , fSrcRect(srcRect) |
27 , fDstRect(dstRect) {} | 27 , fDstRect(dstRect) {} |
28 | 28 |
29 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING | |
30 SkBitmapSource::SkBitmapSource(SkReadBuffer& buffer) : INHERITED(0, buffer) { | |
31 buffer.readBitmap(&fBitmap); | |
32 buffer.readRect(&fSrcRect); | |
33 buffer.readRect(&fDstRect); | |
34 buffer.validate(buffer.isValid() && SkIsValidRect(fSrcRect) && SkIsValidRect
(fDstRect)); | |
35 } | |
36 #endif | |
37 | |
38 SkFlattenable* SkBitmapSource::CreateProc(SkReadBuffer& buffer) { | 29 SkFlattenable* SkBitmapSource::CreateProc(SkReadBuffer& buffer) { |
39 SkRect src, dst; | 30 SkRect src, dst; |
40 buffer.readRect(&src); | 31 buffer.readRect(&src); |
41 buffer.readRect(&dst); | 32 buffer.readRect(&dst); |
42 SkBitmap bitmap; | 33 SkBitmap bitmap; |
43 if (!buffer.readBitmap(&bitmap)) { | 34 if (!buffer.readBitmap(&bitmap)) { |
44 return NULL; | 35 return NULL; |
45 } | 36 } |
46 return SkBitmapSource::Create(bitmap, src, dst); | 37 return SkBitmapSource::Create(bitmap, src, dst); |
47 } | 38 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 | 76 |
86 *result = device.get()->accessBitmap(false); | 77 *result = device.get()->accessBitmap(false); |
87 offset->fX = dstIRect.fLeft; | 78 offset->fX = dstIRect.fLeft; |
88 offset->fY = dstIRect.fTop; | 79 offset->fY = dstIRect.fTop; |
89 return true; | 80 return true; |
90 } | 81 } |
91 | 82 |
92 void SkBitmapSource::computeFastBounds(const SkRect&, SkRect* dst) const { | 83 void SkBitmapSource::computeFastBounds(const SkRect&, SkRect* dst) const { |
93 *dst = fDstRect; | 84 *dst = fDstRect; |
94 } | 85 } |
OLD | NEW |