OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 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 "SkPaint.h" | 8 #include "SkPaint.h" |
9 #include "SkAnnotation.h" | 9 #include "SkAnnotation.h" |
10 #include "SkAutoKern.h" | 10 #include "SkAutoKern.h" |
(...skipping 1928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1939 buffer.writeBool(true); | 1939 buffer.writeBool(true); |
1940 fAnnotation->writeToBuffer(buffer); | 1940 fAnnotation->writeToBuffer(buffer); |
1941 } else { | 1941 } else { |
1942 buffer.writeBool(false); | 1942 buffer.writeBool(false); |
1943 } | 1943 } |
1944 } | 1944 } |
1945 } | 1945 } |
1946 | 1946 |
1947 void SkPaint::unflatten(SkReadBuffer& buffer) { | 1947 void SkPaint::unflatten(SkReadBuffer& buffer) { |
1948 SkASSERT(SkAlign4(kPODPaintSize) == kPODPaintSize); | 1948 SkASSERT(SkAlign4(kPODPaintSize) == kPODPaintSize); |
| 1949 if (!buffer.validateAvailable(kPODPaintSize)) { |
| 1950 return; |
| 1951 } |
1949 const void* podData = buffer.skip(kPODPaintSize); | 1952 const void* podData = buffer.skip(kPODPaintSize); |
1950 const uint32_t* pod = reinterpret_cast<const uint32_t*>(podData); | 1953 const uint32_t* pod = reinterpret_cast<const uint32_t*>(podData); |
1951 | 1954 |
1952 // the order we read must match the order we wrote in flatten() | 1955 // the order we read must match the order we wrote in flatten() |
1953 this->setTextSize(read_scalar(pod)); | 1956 this->setTextSize(read_scalar(pod)); |
1954 this->setTextScaleX(read_scalar(pod)); | 1957 this->setTextScaleX(read_scalar(pod)); |
1955 this->setTextSkewX(read_scalar(pod)); | 1958 this->setTextSkewX(read_scalar(pod)); |
1956 this->setStrokeWidth(read_scalar(pod)); | 1959 this->setStrokeWidth(read_scalar(pod)); |
1957 this->setStrokeMiter(read_scalar(pod)); | 1960 this->setStrokeMiter(read_scalar(pod)); |
1958 this->setColor(*pod++); | 1961 this->setColor(*pod++); |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2420 } | 2423 } |
2421 | 2424 |
2422 uint32_t SkPaint::getHash() const { | 2425 uint32_t SkPaint::getHash() const { |
2423 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB
itfields, | 2426 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB
itfields, |
2424 // so fBitfields should be 10 pointers and 6 32-bit values from the start. | 2427 // so fBitfields should be 10 pointers and 6 32-bit values from the start. |
2425 static_assert(offsetof(SkPaint, fBitfields) == 10 * sizeof(void*) + 6 * size
of(uint32_t), | 2428 static_assert(offsetof(SkPaint, fBitfields) == 10 * sizeof(void*) + 6 * size
of(uint32_t), |
2426 "SkPaint_notPackedTightly"); | 2429 "SkPaint_notPackedTightly"); |
2427 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this), | 2430 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this), |
2428 offsetof(SkPaint, fBitfields) + sizeof(fBitfields
)); | 2431 offsetof(SkPaint, fBitfields) + sizeof(fBitfields
)); |
2429 } | 2432 } |
OLD | NEW |