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
3 // found in the LICENSE file.
5 #include "skia/ext/skia_utils_base.h"
9 bool ReadSkString(base::PickleIterator
* iter
, SkString
* str
) {
11 const char* reply_text
;
13 if (!iter
->ReadData(&reply_text
, &reply_length
))
17 str
->set(reply_text
, reply_length
);
21 bool ReadSkFontIdentity(base::PickleIterator
* iter
,
22 SkFontConfigInterface::FontIdentity
* identity
) {
24 uint32_t reply_ttcIndex
;
26 const char* reply_text
;
28 if (!iter
->ReadUInt32(&reply_id
) ||
29 !iter
->ReadUInt32(&reply_ttcIndex
) ||
30 !iter
->ReadData(&reply_text
, &reply_length
))
34 identity
->fID
= reply_id
;
35 identity
->fTTCIndex
= reply_ttcIndex
;
36 identity
->fString
.set(reply_text
, reply_length
);
41 bool WriteSkString(base::Pickle
* pickle
, const SkString
& str
) {
42 return pickle
->WriteData(str
.c_str(), str
.size());
45 bool WriteSkFontIdentity(base::Pickle
* pickle
,
46 const SkFontConfigInterface::FontIdentity
& identity
) {
47 return pickle
->WriteUInt32(identity
.fID
) &&
48 pickle
->WriteUInt32(identity
.fTTCIndex
) &&
49 WriteSkString(pickle
, identity
.fString
);
52 SkPixelGeometry
ComputeDefaultPixelGeometry() {
53 SkFontHost::LCDOrder order
= SkFontHost::GetSubpixelOrder();
54 if (SkFontHost::kNONE_LCDOrder
== order
) {
55 return kUnknown_SkPixelGeometry
;
57 // Bit0 is RGB(0), BGR(1)
59 const SkPixelGeometry gGeo
[] = {
60 kRGB_H_SkPixelGeometry
,
61 kBGR_H_SkPixelGeometry
,
62 kRGB_V_SkPixelGeometry
,
63 kBGR_V_SkPixelGeometry
,
66 if (SkFontHost::kBGR_LCDOrder
== order
) {
69 if (SkFontHost::kVertical_LCDOrientation
== SkFontHost::GetSubpixelOrientation()){