OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/shared_impl/private/ppb_font_shared.h" | 5 #include "ppapi/shared_impl/private/ppb_font_shared.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "ppapi/c/dev/ppb_font_dev.h" | 10 #include "ppapi/c/dev/ppb_font_dev.h" |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 // the current clip bounds. | 229 // the current clip bounds. |
230 SkRect skclip; | 230 SkRect skclip; |
231 params.destination->getClipBounds(&skclip); | 231 params.destination->getClipBounds(&skclip); |
232 web_clip = WebRect(skclip.fLeft, skclip.fTop, skclip.fRight - skclip.fLeft, | 232 web_clip = WebRect(skclip.fLeft, skclip.fTop, skclip.fRight - skclip.fLeft, |
233 skclip.fBottom - skclip.fTop); | 233 skclip.fBottom - skclip.fTop); |
234 } else { | 234 } else { |
235 web_clip = WebRect(params.clip->point.x, params.clip->point.y, | 235 web_clip = WebRect(params.clip->point.x, params.clip->point.y, |
236 params.clip->size.width, params.clip->size.height); | 236 params.clip->size.width, params.clip->size.height); |
237 } | 237 } |
238 | 238 |
239 #if WEBKIT_USING_SKIA | 239 font_->drawText(params.destination, run, web_position, params.color, web_clip, |
240 WebCanvas* canvas = params.destination; | |
241 #elif WEBKIT_USING_CG | |
242 WebCanvas* canvas = skia::GetBitmapContext(skia::GetTopDevice(*destination)); | |
243 #else | |
244 NOTIMPLEMENTED(); | |
245 return; | |
246 #endif | |
247 font_->drawText(canvas, run, web_position, params.color, web_clip, | |
248 params.image_data_is_opaque == PP_TRUE); | 240 params.image_data_is_opaque == PP_TRUE); |
249 } | 241 } |
250 | 242 |
251 void FontImpl::MeasureText(const TextRun& text, int32_t* result) { | 243 void FontImpl::MeasureText(const TextRun& text, int32_t* result) { |
252 TRACE_EVENT0("ppapi WebKit thread", "FontImpl::MeasureText"); | 244 TRACE_EVENT0("ppapi WebKit thread", "FontImpl::MeasureText"); |
253 *result = font_->calculateWidth(TextRunToWebTextRun(text)); | 245 *result = font_->calculateWidth(TextRunToWebTextRun(text)); |
254 } | 246 } |
255 | 247 |
256 void FontImpl::CharacterOffsetForPixel(const TextRun& text, | 248 void FontImpl::CharacterOffsetForPixel(const TextRun& text, |
257 int32_t pixel_position, | 249 int32_t pixel_position, |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 int32_t result = -1; | 395 int32_t result = -1; |
404 WebKitForwarding::Font::TextRun run; | 396 WebKitForwarding::Font::TextRun run; |
405 if (PPTextRunToTextRun(text, &run)) { | 397 if (PPTextRunToTextRun(text, &run)) { |
406 font_impl_->PixelOffsetForCharacter(run, char_offset, &result); | 398 font_impl_->PixelOffsetForCharacter(run, char_offset, &result); |
407 } | 399 } |
408 return result; | 400 return result; |
409 } | 401 } |
410 | 402 |
411 } // namespace ppapi | 403 } // namespace ppapi |
412 | 404 |
OLD | NEW |