Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(655)

Side by Side Diff: content/child/browser_font_resource_trusted.cc

Issue 975533004: BrowserFontResource should not push opacity info to Blink (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "content/public/common/web_preferences.h" 9 #include "content/public/common/web_preferences.h"
10 #include "ppapi/c/dev/ppb_font_dev.h" 10 #include "ppapi/c/dev/ppb_font_dev.h"
11 #include "ppapi/proxy/connection.h" 11 #include "ppapi/proxy/connection.h"
12 #include "ppapi/shared_impl/ppapi_preferences.h" 12 #include "ppapi/shared_impl/ppapi_preferences.h"
13 #include "ppapi/shared_impl/var.h" 13 #include "ppapi/shared_impl/var.h"
14 #include "ppapi/thunk/enter.h" 14 #include "ppapi/thunk/enter.h"
15 #include "ppapi/thunk/ppb_image_data_api.h" 15 #include "ppapi/thunk/ppb_image_data_api.h"
16 #include "ppapi/thunk/thunk.h" 16 #include "ppapi/thunk/thunk.h"
17 #include "skia/ext/platform_canvas.h" 17 #include "skia/ext/platform_canvas.h"
18 #include "third_party/WebKit/public/platform/WebCanvas.h" 18 #include "third_party/WebKit/public/platform/WebCanvas.h"
19 #include "third_party/WebKit/public/platform/WebFloatPoint.h" 19 #include "third_party/WebKit/public/platform/WebFloatPoint.h"
20 #include "third_party/WebKit/public/platform/WebFloatRect.h" 20 #include "third_party/WebKit/public/platform/WebFloatRect.h"
21 #include "third_party/WebKit/public/platform/WebRect.h" 21 #include "third_party/WebKit/public/platform/WebRect.h"
22 #include "third_party/WebKit/public/web/WebFont.h" 22 #include "third_party/WebKit/public/web/WebFont.h"
23 #include "third_party/WebKit/public/web/WebFontDescription.h" 23 #include "third_party/WebKit/public/web/WebFontDescription.h"
24 #include "third_party/WebKit/public/web/WebTextRun.h" 24 #include "third_party/WebKit/public/web/WebTextRun.h"
25 #include "third_party/icu/source/common/unicode/ubidi.h" 25 #include "third_party/icu/source/common/unicode/ubidi.h"
26 #include "third_party/skia/include/core/SkRect.h" 26 #include "third_party/skia/include/core/SkRect.h"
27 #include "third_party/skia/include/effects/SkPaintFlagsDrawFilter.h"
27 28
28 using ppapi::StringVar; 29 using ppapi::StringVar;
29 using ppapi::thunk::EnterResourceNoLock; 30 using ppapi::thunk::EnterResourceNoLock;
30 using ppapi::thunk::PPB_ImageData_API; 31 using ppapi::thunk::PPB_ImageData_API;
31 using blink::WebFloatPoint; 32 using blink::WebFloatPoint;
32 using blink::WebFloatRect; 33 using blink::WebFloatRect;
33 using blink::WebFont; 34 using blink::WebFont;
34 using blink::WebFontDescription; 35 using blink::WebFontDescription;
35 using blink::WebRect; 36 using blink::WebRect;
36 using blink::WebTextRun; 37 using blink::WebTextRun;
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 // the current clip bounds. 403 // the current clip bounds.
403 SkRect skclip; 404 SkRect skclip;
404 destination->getClipBounds(&skclip); 405 destination->getClipBounds(&skclip);
405 web_clip = WebRect(skclip.fLeft, skclip.fTop, skclip.fRight - skclip.fLeft, 406 web_clip = WebRect(skclip.fLeft, skclip.fTop, skclip.fRight - skclip.fLeft,
406 skclip.fBottom - skclip.fTop); 407 skclip.fBottom - skclip.fTop);
407 } else { 408 } else {
408 web_clip = WebRect(clip->point.x, clip->point.y, 409 web_clip = WebRect(clip->point.x, clip->point.y,
409 clip->size.width, clip->size.height); 410 clip->size.width, clip->size.height);
410 } 411 }
411 412
413 SkAutoCanvasRestore auto_restore(destination, false);
414 if (!PP_ToBool(image_data_is_opaque)) {
415 // Ideally, LCD text should be configured at canvas creation time using
416 // SkSurfaceProps. But because the API exposes image_data_is_opaque per
417 // draw text call (allowing clients to essentially change their mind),
418 // we have to handle it here.
419 destination->save();
reed1 2015/03/03 15:04:42 save(); // will be balanced automatically by auto_
420 skia::RefPtr<SkDrawFilter> lcd_filter = skia::AdoptRef(
421 new SkPaintFlagsDrawFilter(SkPaint::kLCDRenderText_Flag, 0));
422 destination->setDrawFilter(lcd_filter.get());
423 }
424
412 TextRunCollection runs(text); 425 TextRunCollection runs(text);
413 for (int i = 0; i < runs.num_runs(); i++) { 426 for (int i = 0; i < runs.num_runs(); i++) {
414 int32_t run_begin = 0; 427 int32_t run_begin = 0;
415 int32_t run_len = 0; 428 int32_t run_len = 0;
416 WebTextRun run = runs.GetRunAt(i, &run_begin, &run_len); 429 WebTextRun run = runs.GetRunAt(i, &run_begin, &run_len);
417 font_->drawText(destination, run, web_position, color, web_clip, 430 font_->drawText(destination, run, web_position, color, web_clip);
418 PP_ToBool(image_data_is_opaque));
419 431
420 // Advance to the next run. Note that we avoid doing this for the last run 432 // Advance to the next run. Note that we avoid doing this for the last run
421 // since it's unnecessary, measuring text is slow, and most of the time 433 // since it's unnecessary, measuring text is slow, and most of the time
422 // there will be only one run anyway. 434 // there will be only one run anyway.
423 if (i != runs.num_runs() - 1) 435 if (i != runs.num_runs() - 1)
424 web_position.x += font_->calculateWidth(run); 436 web_position.x += font_->calculateWidth(run);
425 } 437 }
426 } 438 }
427 439
428 } // namespace content 440 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698