Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include "skia/ext/skia_utils_base.h" | 7 #include "skia/ext/skia_utils_base.h" |
| 8 | 8 |
| 9 namespace skia { | 9 namespace skia { |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 return false; | 33 return false; |
| 34 | 34 |
| 35 if (identity) { | 35 if (identity) { |
| 36 identity->fID = reply_id; | 36 identity->fID = reply_id; |
| 37 identity->fTTCIndex = reply_ttcIndex; | 37 identity->fTTCIndex = reply_ttcIndex; |
| 38 identity->fString.set(reply_text, reply_length); | 38 identity->fString.set(reply_text, reply_length); |
| 39 } | 39 } |
| 40 return true; | 40 return true; |
| 41 } | 41 } |
| 42 | 42 |
| 43 bool ReadSkFontStyle(base::PickleIterator* iter, SkFontStyle* style) { | |
| 44 uint16_t reply_weight; | |
| 45 uint16_t reply_width; | |
| 46 uint16_t reply_slant; | |
| 47 | |
| 48 if (!iter->ReadUInt16(&reply_weight) || | |
| 49 !iter->ReadUInt16(&reply_width) || | |
| 50 !iter->ReadUInt16(&reply_slant)) | |
| 51 return false; | |
| 52 | |
| 53 if (style) { | |
|
dcheng
2016/04/12 17:11:23
Seems odd that this is an optional parameter. It d
bungeman-chromium
2016/04/12 18:15:38
I think the original intent was to avoid the local
bungeman-chromium
2016/04/12 18:47:04
To provide an example, taking advantage of the way
| |
| 54 *style = SkFontStyle(reply_weight, | |
| 55 reply_width, | |
| 56 static_cast<SkFontStyle::Slant>(reply_slant)); | |
| 57 } | |
| 58 return true; | |
| 59 } | |
| 60 | |
| 43 bool WriteSkString(base::Pickle* pickle, const SkString& str) { | 61 bool WriteSkString(base::Pickle* pickle, const SkString& str) { |
| 44 return pickle->WriteData(str.c_str(), str.size()); | 62 return pickle->WriteData(str.c_str(), str.size()); |
| 45 } | 63 } |
| 46 | 64 |
| 47 bool WriteSkFontIdentity(base::Pickle* pickle, | 65 bool WriteSkFontIdentity(base::Pickle* pickle, |
| 48 const SkFontConfigInterface::FontIdentity& identity) { | 66 const SkFontConfigInterface::FontIdentity& identity) { |
| 49 return pickle->WriteUInt32(identity.fID) && | 67 return pickle->WriteUInt32(identity.fID) && |
| 50 pickle->WriteUInt32(identity.fTTCIndex) && | 68 pickle->WriteUInt32(identity.fTTCIndex) && |
| 51 WriteSkString(pickle, identity.fString); | 69 WriteSkString(pickle, identity.fString); |
| 52 } | 70 } |
| 53 | 71 |
| 72 bool WriteSkFontStyle(base::Pickle* pickle, SkFontStyle style) { | |
| 73 return pickle->WriteUInt16(style.weight()) && | |
| 74 pickle->WriteUInt16(style.width()) && | |
| 75 pickle->WriteUInt16(style.slant()); | |
| 76 } | |
| 77 | |
| 54 SkPixelGeometry ComputeDefaultPixelGeometry() { | 78 SkPixelGeometry ComputeDefaultPixelGeometry() { |
| 55 SkFontHost::LCDOrder order = SkFontHost::GetSubpixelOrder(); | 79 SkFontHost::LCDOrder order = SkFontHost::GetSubpixelOrder(); |
| 56 if (SkFontHost::kNONE_LCDOrder == order) { | 80 if (SkFontHost::kNONE_LCDOrder == order) { |
| 57 return kUnknown_SkPixelGeometry; | 81 return kUnknown_SkPixelGeometry; |
| 58 } else { | 82 } else { |
| 59 // Bit0 is RGB(0), BGR(1) | 83 // Bit0 is RGB(0), BGR(1) |
| 60 // Bit1 is H(0), V(1) | 84 // Bit1 is H(0), V(1) |
| 61 const SkPixelGeometry gGeo[] = { | 85 const SkPixelGeometry gGeo[] = { |
| 62 kRGB_H_SkPixelGeometry, | 86 kRGB_H_SkPixelGeometry, |
| 63 kBGR_H_SkPixelGeometry, | 87 kBGR_H_SkPixelGeometry, |
| 64 kRGB_V_SkPixelGeometry, | 88 kRGB_V_SkPixelGeometry, |
| 65 kBGR_V_SkPixelGeometry, | 89 kBGR_V_SkPixelGeometry, |
| 66 }; | 90 }; |
| 67 int index = 0; | 91 int index = 0; |
| 68 if (SkFontHost::kBGR_LCDOrder == order) { | 92 if (SkFontHost::kBGR_LCDOrder == order) { |
| 69 index |= 1; | 93 index |= 1; |
| 70 } | 94 } |
| 71 if (SkFontHost::kVertical_LCDOrientation == SkFontHost::GetSubpixelOrien tation()){ | 95 if (SkFontHost::kVertical_LCDOrientation == SkFontHost::GetSubpixelOrien tation()){ |
| 72 index |= 2; | 96 index |= 2; |
| 73 } | 97 } |
| 74 return gGeo[index]; | 98 return gGeo[index]; |
| 75 } | 99 } |
| 76 } | 100 } |
| 77 | 101 |
| 78 } // namespace skia | 102 } // namespace skia |
| 79 | 103 |
| OLD | NEW |