Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: src/core/SkPaint.cpp

Issue 770703002: Bump min picture version. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: TODO Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/core/SkLocalMatrixShader.cpp ('k') | src/core/SkPicture.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1781 matching lines...) Expand 10 before | Expand all | Expand 10 after
1792 SkASSERT(bitCount > 0 && bitCount <= 32); 1792 SkASSERT(bitCount > 0 && bitCount <= 32);
1793 uint32_t mask = ~0U; 1793 uint32_t mask = ~0U;
1794 mask >>= (32 - bitCount); 1794 mask >>= (32 - bitCount);
1795 SkASSERT(0 == (value & ~mask)); 1795 SkASSERT(0 == (value & ~mask));
1796 } 1796 }
1797 #else 1797 #else
1798 #define ASSERT_FITS_IN(value, bitcount) 1798 #define ASSERT_FITS_IN(value, bitcount)
1799 #endif 1799 #endif
1800 1800
1801 enum FlatFlags { 1801 enum FlatFlags {
1802 kHasTypeface_FlatFlag = 0x01, 1802 kHasTypeface_FlatFlag = 0x1,
1803 kHasEffects_FlatFlag = 0x02, 1803 kHasEffects_FlatFlag = 0x2,
1804 kHasNonDefaultPaintOptionsAndroid_FlatFlag = 0x04,
1805 1804
1806 kFlatFlagMask = 0x7, 1805 kFlatFlagMask = 0x3,
1807 }; 1806 };
1808 1807
1809 enum BitsPerField { 1808 enum BitsPerField {
1810 kFlags_BPF = 16, 1809 kFlags_BPF = 16,
1811 kHint_BPF = 2, 1810 kHint_BPF = 2,
1812 kAlign_BPF = 2, 1811 kAlign_BPF = 2,
1813 kFilter_BPF = 2, 1812 kFilter_BPF = 2,
1814 kFlatFlags_BPF = 3, 1813 kFlatFlags_BPF = 3,
1815 }; 1814 };
1816 1815
(...skipping 15 matching lines...) Expand all
1832 } 1831 }
1833 1832
1834 static FlatFlags unpack_paint_flags(SkPaint* paint, uint32_t packed) { 1833 static FlatFlags unpack_paint_flags(SkPaint* paint, uint32_t packed) {
1835 paint->setFlags(packed >> 16); 1834 paint->setFlags(packed >> 16);
1836 paint->setHinting((SkPaint::Hinting)((packed >> 14) & BPF_Mask(kHint_BPF))); 1835 paint->setHinting((SkPaint::Hinting)((packed >> 14) & BPF_Mask(kHint_BPF)));
1837 paint->setTextAlign((SkPaint::Align)((packed >> 12) & BPF_Mask(kAlign_BPF))) ; 1836 paint->setTextAlign((SkPaint::Align)((packed >> 12) & BPF_Mask(kAlign_BPF))) ;
1838 paint->setFilterLevel((SkPaint::FilterLevel)((packed >> 10) & BPF_Mask(kFilt er_BPF))); 1837 paint->setFilterLevel((SkPaint::FilterLevel)((packed >> 10) & BPF_Mask(kFilt er_BPF)));
1839 return (FlatFlags)(packed & kFlatFlagMask); 1838 return (FlatFlags)(packed & kFlatFlagMask);
1840 } 1839 }
1841 1840
1842 // V22_COMPATIBILITY_CODE
1843 static FlatFlags unpack_paint_flags_v22(SkPaint* paint, uint32_t packed) {
1844 enum {
1845 kFilterBitmap_Flag = 0x02,
1846 kHighQualityFilterBitmap_Flag = 0x4000,
1847
1848 kAll_Flags = kFilterBitmap_Flag | kHighQualityFilterBitmap_Flag
1849 };
1850
1851 // previously flags:16, textAlign:8, flatFlags:8
1852 // now flags:16, hinting:4, textAlign:4, flatFlags:8
1853 unsigned flags = packed >> 16;
1854 int filter = 0;
1855 if (flags & kFilterBitmap_Flag) {
1856 filter |= 1;
1857 }
1858 if (flags & kHighQualityFilterBitmap_Flag) {
1859 filter |= 2;
1860 }
1861 paint->setFilterLevel((SkPaint::FilterLevel)filter);
1862 flags &= ~kAll_Flags; // remove these (now dead) bit flags
1863
1864 paint->setFlags(flags);
1865
1866 // hinting added later. 0 in this nibble means use the default.
1867 uint32_t hinting = (packed >> 12) & 0xF;
1868 paint->setHinting(0 == hinting ? SkPaint::kNormal_Hinting : static_cast<SkPa int::Hinting>(hinting-1));
1869 paint->setTextAlign(static_cast<SkPaint::Align>((packed >> 8) & 0xF));
1870 return (FlatFlags)(packed & kFlatFlagMask);
1871 }
1872
1873 // The size of a flat paint's POD fields 1841 // The size of a flat paint's POD fields
1874 static const uint32_t kPODPaintSize = 5 * sizeof(SkScalar) + 1842 static const uint32_t kPODPaintSize = 5 * sizeof(SkScalar) +
1875 1 * sizeof(SkColor) + 1843 1 * sizeof(SkColor) +
1876 1 * sizeof(uint16_t) + 1844 1 * sizeof(uint16_t) +
1877 6 * sizeof(uint8_t); 1845 6 * sizeof(uint8_t);
1878 1846
1879 /* To save space/time, we analyze the paint, and write a truncated version of 1847 /* To save space/time, we analyze the paint, and write a truncated version of
1880 it if there are not tricky elements like shaders, etc. 1848 it if there are not tricky elements like shaders, etc.
1881 */ 1849 */
1882 void SkPaint::flatten(SkWriteBuffer& buffer) const { 1850 void SkPaint::flatten(SkWriteBuffer& buffer) const {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1941 const uint32_t* pod = reinterpret_cast<const uint32_t*>(podData); 1909 const uint32_t* pod = reinterpret_cast<const uint32_t*>(podData);
1942 1910
1943 // the order we read must match the order we wrote in flatten() 1911 // the order we read must match the order we wrote in flatten()
1944 this->setTextSize(read_scalar(pod)); 1912 this->setTextSize(read_scalar(pod));
1945 this->setTextScaleX(read_scalar(pod)); 1913 this->setTextScaleX(read_scalar(pod));
1946 this->setTextSkewX(read_scalar(pod)); 1914 this->setTextSkewX(read_scalar(pod));
1947 this->setStrokeWidth(read_scalar(pod)); 1915 this->setStrokeWidth(read_scalar(pod));
1948 this->setStrokeMiter(read_scalar(pod)); 1916 this->setStrokeMiter(read_scalar(pod));
1949 this->setColor(*pod++); 1917 this->setColor(*pod++);
1950 1918
1951 unsigned flatFlags = 0; 1919 unsigned flatFlags = unpack_paint_flags(this, *pod++);
1952 if (buffer.isVersionLT(SkReadBuffer::kFilterLevelIsEnum_Version)) {
1953 flatFlags = unpack_paint_flags_v22(this, *pod++);
1954 } else {
1955 flatFlags = unpack_paint_flags(this, *pod++);
1956 }
1957 1920
1958 uint32_t tmp = *pod++; 1921 uint32_t tmp = *pod++;
1959 this->setStrokeCap(static_cast<Cap>((tmp >> 24) & 0xFF)); 1922 this->setStrokeCap(static_cast<Cap>((tmp >> 24) & 0xFF));
1960 this->setStrokeJoin(static_cast<Join>((tmp >> 16) & 0xFF)); 1923 this->setStrokeJoin(static_cast<Join>((tmp >> 16) & 0xFF));
1961 this->setStyle(static_cast<Style>((tmp >> 8) & 0xFF)); 1924 this->setStyle(static_cast<Style>((tmp >> 8) & 0xFF));
1962 this->setTextEncoding(static_cast<TextEncoding>((tmp >> 0) & 0xFF)); 1925 this->setTextEncoding(static_cast<TextEncoding>((tmp >> 0) & 0xFF));
1963 1926
1964 if (flatFlags & kHasTypeface_FlatFlag) { 1927 if (flatFlags & kHasTypeface_FlatFlag) {
1965 this->setTypeface(buffer.readTypeface()); 1928 this->setTypeface(buffer.readTypeface());
1966 } else { 1929 } else {
(...skipping 16 matching lines...) Expand all
1983 } else { 1946 } else {
1984 this->setPathEffect(NULL); 1947 this->setPathEffect(NULL);
1985 this->setShader(NULL); 1948 this->setShader(NULL);
1986 this->setXfermode(NULL); 1949 this->setXfermode(NULL);
1987 this->setMaskFilter(NULL); 1950 this->setMaskFilter(NULL);
1988 this->setColorFilter(NULL); 1951 this->setColorFilter(NULL);
1989 this->setRasterizer(NULL); 1952 this->setRasterizer(NULL);
1990 this->setLooper(NULL); 1953 this->setLooper(NULL);
1991 this->setImageFilter(NULL); 1954 this->setImageFilter(NULL);
1992 } 1955 }
1993
1994 if (buffer.isVersionLT(SkReadBuffer::kRemoveAndroidPaintOpts_Version) &&
1995 flatFlags & kHasNonDefaultPaintOptionsAndroid_FlatFlag) {
1996 SkString tag;
1997 buffer.readUInt();
1998 buffer.readString(&tag);
1999 buffer.readBool();
2000 }
2001 } 1956 }
2002 1957
2003 /////////////////////////////////////////////////////////////////////////////// 1958 ///////////////////////////////////////////////////////////////////////////////
2004 1959
2005 SkShader* SkPaint::setShader(SkShader* shader) { 1960 SkShader* SkPaint::setShader(SkShader* shader) {
2006 SkRefCnt_SafeAssign(fShader, shader); 1961 SkRefCnt_SafeAssign(fShader, shader);
2007 return shader; 1962 return shader;
2008 } 1963 }
2009 1964
2010 SkColorFilter* SkPaint::setColorFilter(SkColorFilter* filter) { 1965 SkColorFilter* SkPaint::setColorFilter(SkColorFilter* filter) {
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
2414 } 2369 }
2415 2370
2416 uint32_t SkPaint::getHash() const { 2371 uint32_t SkPaint::getHash() const {
2417 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB itfields, 2372 // We're going to hash 10 pointers and 7 32-bit values, finishing up with fB itfields,
2418 // so fBitfields should be 10 pointers and 6 32-bit values from the start. 2373 // so fBitfields should be 10 pointers and 6 32-bit values from the start.
2419 SK_COMPILE_ASSERT(offsetof(SkPaint, fBitfields) == 10 * sizeof(void*) + 6 * sizeof(uint32_t), 2374 SK_COMPILE_ASSERT(offsetof(SkPaint, fBitfields) == 10 * sizeof(void*) + 6 * sizeof(uint32_t),
2420 SkPaint_notPackedTightly); 2375 SkPaint_notPackedTightly);
2421 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this), 2376 return SkChecksum::Murmur3(reinterpret_cast<const uint32_t*>(this),
2422 offsetof(SkPaint, fBitfields) + sizeof(fBitfields )); 2377 offsetof(SkPaint, fBitfields) + sizeof(fBitfields ));
2423 } 2378 }
OLDNEW
« no previous file with comments | « src/core/SkLocalMatrixShader.cpp ('k') | src/core/SkPicture.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698