| 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 "content/child/browser_font_resource_trusted.h" | 5 #include "content/child/browser_font_resource_trusted.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "cc/paint/skia_paint_canvas.h" |
| 12 #include "content/public/common/web_preferences.h" | 13 #include "content/public/common/web_preferences.h" |
| 13 #include "ppapi/proxy/connection.h" | 14 #include "ppapi/proxy/connection.h" |
| 14 #include "ppapi/shared_impl/ppapi_preferences.h" | 15 #include "ppapi/shared_impl/ppapi_preferences.h" |
| 15 #include "ppapi/shared_impl/var.h" | 16 #include "ppapi/shared_impl/var.h" |
| 16 #include "ppapi/thunk/enter.h" | 17 #include "ppapi/thunk/enter.h" |
| 17 #include "ppapi/thunk/ppb_image_data_api.h" | 18 #include "ppapi/thunk/ppb_image_data_api.h" |
| 18 #include "ppapi/thunk/thunk.h" | 19 #include "ppapi/thunk/thunk.h" |
| 19 #include "skia/ext/platform_canvas.h" | 20 #include "skia/ext/platform_canvas.h" |
| 20 #include "third_party/WebKit/public/platform/WebCanvas.h" | 21 #include "third_party/WebKit/public/platform/WebCanvas.h" |
| 21 #include "third_party/WebKit/public/platform/WebFloatPoint.h" | 22 #include "third_party/WebKit/public/platform/WebFloatPoint.h" |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 size_t row_bytes; | 335 size_t row_bytes; |
| 335 void* pixels = canvas->accessTopLayerPixels(&info, &row_bytes); | 336 void* pixels = canvas->accessTopLayerPixels(&info, &row_bytes); |
| 336 if (!pixels) | 337 if (!pixels) |
| 337 return result; | 338 return result; |
| 338 | 339 |
| 339 SkBitmap bm; | 340 SkBitmap bm; |
| 340 if (!bm.installPixels(info, pixels, row_bytes)) | 341 if (!bm.installPixels(info, pixels, row_bytes)) |
| 341 return result; | 342 return result; |
| 342 | 343 |
| 343 SkSurfaceProps props(0, kUnknown_SkPixelGeometry); | 344 SkSurfaceProps props(0, kUnknown_SkPixelGeometry); |
| 344 cc::PaintCanvas temp_canvas(bm, props); | 345 cc::SkiaPaintCanvas temp_canvas(bm, props); |
| 345 | 346 |
| 346 DrawTextToCanvas(&temp_canvas, *text, position, color, clip); | 347 DrawTextToCanvas(&temp_canvas, *text, position, color, clip); |
| 347 } else { | 348 } else { |
| 348 cc::PaintCanvas temp_canvas(canvas); | 349 cc::SkiaPaintCanvas temp_canvas(canvas); |
| 349 DrawTextToCanvas(&temp_canvas, *text, position, color, clip); | 350 DrawTextToCanvas(&temp_canvas, *text, position, color, clip); |
| 350 } | 351 } |
| 351 | 352 |
| 352 if (needs_unmapping) | 353 if (needs_unmapping) |
| 353 image->Unmap(); | 354 image->Unmap(); |
| 354 return PP_TRUE; | 355 return PP_TRUE; |
| 355 } | 356 } |
| 356 | 357 |
| 357 int32_t BrowserFontResource_Trusted::MeasureText( | 358 int32_t BrowserFontResource_Trusted::MeasureText( |
| 358 const PP_BrowserFont_Trusted_TextRun* text) { | 359 const PP_BrowserFont_Trusted_TextRun* text) { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 | 445 |
| 445 // Advance to the next run. Note that we avoid doing this for the last run | 446 // Advance to the next run. Note that we avoid doing this for the last run |
| 446 // since it's unnecessary, measuring text is slow, and most of the time | 447 // since it's unnecessary, measuring text is slow, and most of the time |
| 447 // there will be only one run anyway. | 448 // there will be only one run anyway. |
| 448 if (i != runs.num_runs() - 1) | 449 if (i != runs.num_runs() - 1) |
| 449 web_position.x += font_->calculateWidth(run); | 450 web_position.x += font_->calculateWidth(run); |
| 450 } | 451 } |
| 451 } | 452 } |
| 452 | 453 |
| 453 } // namespace content | 454 } // namespace content |
| OLD | NEW |