| 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 "skia/ext/skia_utils_base.h" |
| 6 |
| 5 #include <stdint.h> | 7 #include <stdint.h> |
| 6 | 8 |
| 7 #include "skia/ext/skia_utils_base.h" | |
| 8 #include "third_party/skia/include/core/SkFontLCDConfig.h" | 9 #include "third_party/skia/include/core/SkFontLCDConfig.h" |
| 10 #include "third_party/skia/src/core/SkReadBuffer.h" |
| 9 | 11 |
| 10 namespace skia { | 12 namespace skia { |
| 11 | 13 |
| 12 bool ReadSkString(base::PickleIterator* iter, SkString* str) { | 14 bool ReadSkString(base::PickleIterator* iter, SkString* str) { |
| 13 int reply_length; | 15 int reply_length; |
| 14 const char* reply_text; | 16 const char* reply_text; |
| 15 | 17 |
| 16 if (!iter->ReadData(&reply_text, &reply_length)) | 18 if (!iter->ReadData(&reply_text, &reply_length)) |
| 17 return false; | 19 return false; |
| 18 | 20 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 if (SkFontLCDConfig::kBGR_LCDOrder == order) { | 96 if (SkFontLCDConfig::kBGR_LCDOrder == order) { |
| 95 index |= 1; | 97 index |= 1; |
| 96 } | 98 } |
| 97 if (SkFontLCDConfig::kVertical_LCDOrientation == | 99 if (SkFontLCDConfig::kVertical_LCDOrientation == |
| 98 SkFontLCDConfig::GetSubpixelOrientation()) { | 100 SkFontLCDConfig::GetSubpixelOrientation()) { |
| 99 index |= 2; | 101 index |= 2; |
| 100 } | 102 } |
| 101 return gGeo[index]; | 103 return gGeo[index]; |
| 102 } | 104 } |
| 103 | 105 |
| 106 std::unique_ptr<SkDrawable> ReadDrawable(const char* buffer, size_t size) { |
| 107 SkReadBuffer rBuffer(buffer, size); |
| 108 rBuffer.setCustomFactory(SkString(SkFutureDrawable::kTypeName), |
| 109 SkFutureDrawable::CreateProc); |
| 110 |
| 111 std::unique_ptr<SkDrawable> drawable( |
| 112 (SkDrawable*)rBuffer.readFlattenable(SkFlattenable::kSkDrawable_Type)); |
| 113 return drawable; |
| 114 } |
| 115 |
| 116 std::vector<char> WriteDrawable(SkDrawable* drawable) { |
| 117 SkBinaryWriteBuffer wBuffer; |
| 118 wBuffer.writeFlattenable(drawable); |
| 119 size_t size = wBuffer.bytesWritten(); |
| 120 std::vector<char> data; |
| 121 data.resize(size); |
| 122 wBuffer.writeToMemory(data.data()); |
| 123 return data; |
| 124 } |
| 125 |
| 104 } // namespace skia | 126 } // namespace skia |
| 105 | 127 |
| OLD | NEW |