| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "ppapi/cpp/trusted/browser_font_trusted.h" | 5 #include "ppapi/cpp/trusted/browser_font_trusted.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ppapi/c/dev/ppb_font_dev.h" | 9 #include "ppapi/c/dev/ppb_font_dev.h" |
| 10 #include "ppapi/cpp/image_data.h" | 10 #include "ppapi/cpp/image_data.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 BrowserFont_Trusted& BrowserFont_Trusted::operator=( | 151 BrowserFont_Trusted& BrowserFont_Trusted::operator=( |
| 152 const BrowserFont_Trusted& other) { | 152 const BrowserFont_Trusted& other) { |
| 153 Resource::operator=(other); | 153 Resource::operator=(other); |
| 154 return *this; | 154 return *this; |
| 155 } | 155 } |
| 156 | 156 |
| 157 // static | 157 // static |
| 158 Var BrowserFont_Trusted::GetFontFamilies(Instance* instance) { | 158 Var BrowserFont_Trusted::GetFontFamilies(Instance* instance) { |
| 159 if (!has_interface<PPB_Font_Dev>()) | 159 if (!has_interface<PPB_Font_Dev>()) |
| 160 return Var(); | 160 return Var(); |
| 161 return Var(Var::PassRef(), | 161 return Var(PASS_REF, |
| 162 get_interface<PPB_Font_Dev>()->GetFontFamilies( | 162 get_interface<PPB_Font_Dev>()->GetFontFamilies( |
| 163 instance->pp_instance())); | 163 instance->pp_instance())); |
| 164 } | 164 } |
| 165 | 165 |
| 166 bool BrowserFont_Trusted::Describe( | 166 bool BrowserFont_Trusted::Describe( |
| 167 BrowserFontDescription* description, | 167 BrowserFontDescription* description, |
| 168 PP_BrowserFont_Trusted_Metrics* metrics) const { | 168 PP_BrowserFont_Trusted_Metrics* metrics) const { |
| 169 // Be careful with ownership of the |face| string. It will come back with | 169 // Be careful with ownership of the |face| string. It will come back with |
| 170 // a ref of 1, which we want to assign to the |face_| member of the C++ class. | 170 // a ref of 1, which we want to assign to the |face_| member of the C++ class. |
| 171 if (has_interface<PPB_BrowserFont_Trusted>()) { | 171 if (has_interface<PPB_BrowserFont_Trusted>()) { |
| 172 if (!get_interface<PPB_BrowserFont_Trusted>()->Describe( | 172 if (!get_interface<PPB_BrowserFont_Trusted>()->Describe( |
| 173 pp_resource(), &description->pp_font_description_, metrics)) | 173 pp_resource(), &description->pp_font_description_, metrics)) |
| 174 return false; | 174 return false; |
| 175 } else if (!has_interface<PPB_Font_Dev>()) { | 175 } else if (!has_interface<PPB_Font_Dev>()) { |
| 176 if (!get_interface<PPB_Font_Dev>()->Describe( | 176 if (!get_interface<PPB_Font_Dev>()->Describe( |
| 177 pp_resource(), | 177 pp_resource(), |
| 178 BrowserFontDescToFontDesc(&description->pp_font_description_), | 178 BrowserFontDescToFontDesc(&description->pp_font_description_), |
| 179 BrowserFontMetricsToFontMetrics(metrics))) | 179 BrowserFontMetricsToFontMetrics(metrics))) |
| 180 return false; | 180 return false; |
| 181 } | 181 } |
| 182 description->face_ = Var(Var::PassRef(), | 182 description->face_ = Var(PASS_REF, |
| 183 description->pp_font_description_.face); | 183 description->pp_font_description_.face); |
| 184 return true; | 184 return true; |
| 185 } | 185 } |
| 186 | 186 |
| 187 bool BrowserFont_Trusted::DrawTextAt(ImageData* dest, | 187 bool BrowserFont_Trusted::DrawTextAt(ImageData* dest, |
| 188 const BrowserFontTextRun& text, | 188 const BrowserFontTextRun& text, |
| 189 const Point& position, | 189 const Point& position, |
| 190 uint32_t color, | 190 uint32_t color, |
| 191 const Rect& clip, | 191 const Rect& clip, |
| 192 bool image_data_is_opaque) const { | 192 bool image_data_is_opaque) const { |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 bool image_data_is_opaque) const { | 267 bool image_data_is_opaque) const { |
| 268 return DrawTextAt(dest, BrowserFontTextRun(text), position, color, | 268 return DrawTextAt(dest, BrowserFontTextRun(text), position, color, |
| 269 Rect(dest->size()), image_data_is_opaque); | 269 Rect(dest->size()), image_data_is_opaque); |
| 270 } | 270 } |
| 271 | 271 |
| 272 int32_t BrowserFont_Trusted::MeasureSimpleText(const std::string& text) const { | 272 int32_t BrowserFont_Trusted::MeasureSimpleText(const std::string& text) const { |
| 273 return MeasureText(BrowserFontTextRun(text)); | 273 return MeasureText(BrowserFontTextRun(text)); |
| 274 } | 274 } |
| 275 | 275 |
| 276 } // namespace pp | 276 } // namespace pp |
| OLD | NEW |