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

Side by Side Diff: ui/gfx/canvas_skia_win.cc

Issue 8681001: Revert 111288 - Possibly broke media_unittests on Mac (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « ui/gfx/canvas_skia.cc ('k') | ui/gfx/render_text.cc » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "ui/gfx/canvas_skia.h" 5 #include "ui/gfx/canvas_skia.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/i18n/rtl.h" 9 #include "base/i18n/rtl.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 const SkColor& text_color, 408 const SkColor& text_color,
409 const SkColor& halo_color_in, 409 const SkColor& halo_color_in,
410 int x, int y, int w, int h, 410 int x, int y, int w, int h,
411 int flags) { 411 int flags) {
412 // Some callers will have semitransparent halo colors, which we don't handle 412 // Some callers will have semitransparent halo colors, which we don't handle
413 // (since the resulting image can have 1-bit transparency only). 413 // (since the resulting image can have 1-bit transparency only).
414 SkColor halo_color = halo_color_in | 0xFF000000; 414 SkColor halo_color = halo_color_in | 0xFF000000;
415 415
416 // Create a temporary buffer filled with the halo color. It must leave room 416 // Create a temporary buffer filled with the halo color. It must leave room
417 // for the 1-pixel border around the text. 417 // for the 1-pixel border around the text.
418 gfx::Rect rect(gfx::Point(), gfx::Size(w + 2, h + 2)); 418 CanvasSkia text_canvas(w + 2, h + 2, true);
419 CanvasSkia text_canvas(rect.width(), rect.height(), true);
420 SkPaint bkgnd_paint; 419 SkPaint bkgnd_paint;
421 bkgnd_paint.setColor(halo_color); 420 bkgnd_paint.setColor(halo_color);
422 text_canvas.DrawRect(rect, bkgnd_paint); 421 text_canvas.DrawRectInt(0, 0, w + 2, h + 2, bkgnd_paint);
423 422
424 // Draw the text into the temporary buffer. This will have correct 423 // Draw the text into the temporary buffer. This will have correct
425 // ClearType since the background color is the same as the halo color. 424 // ClearType since the background color is the same as the halo color.
426 text_canvas.DrawStringInt(text, font, text_color, 1, 1, w, h, flags); 425 text_canvas.DrawStringInt(text, font, text_color, 1, 1, w, h, flags);
427 426
428 // Windows will have cleared the alpha channel for the pixels it drew. Make it 427 // Windows will have cleared the alpha channel for the pixels it drew. Make it
429 // opaque. We have to do this first since pixelShouldGetHalo will check for 428 // opaque. We have to do this first since pixelShouldGetHalo will check for
430 // 0 to see if a pixel has been modified to transparent, and black text that 429 // 0 to see if a pixel has been modified to transparent, and black text that
431 // Windows draw will look transparent to it! 430 // Windows draw will look transparent to it!
432 skia::MakeOpaque(text_canvas.sk_canvas(), rect.x(), rect.y(), rect.width(), 431 skia::MakeOpaque(text_canvas.sk_canvas(), 0, 0, w + 2, h + 2);
433 rect.height());
434 432
435 uint32_t halo_premul = SkPreMultiplyColor(halo_color); 433 uint32_t halo_premul = SkPreMultiplyColor(halo_color);
436 SkBitmap& text_bitmap = const_cast<SkBitmap&>( 434 SkBitmap& text_bitmap = const_cast<SkBitmap&>(
437 skia::GetTopDevice(*text_canvas.sk_canvas())->accessBitmap(true)); 435 skia::GetTopDevice(*text_canvas.sk_canvas())->accessBitmap(true));
438 for (int cur_y = 0; cur_y < h + 2; cur_y++) { 436 for (int cur_y = 0; cur_y < h + 2; cur_y++) {
439 uint32_t* text_row = text_bitmap.getAddr32(0, cur_y); 437 uint32_t* text_row = text_bitmap.getAddr32(0, cur_y);
440 for (int cur_x = 0; cur_x < w + 2; cur_x++) { 438 for (int cur_x = 0; cur_x < w + 2; cur_x++) {
441 if (text_row[cur_x] == halo_premul) { 439 if (text_row[cur_x] == halo_premul) {
442 // This pixel was not touched by the text routines. See if it borders 440 // This pixel was not touched by the text routines. See if it borders
443 // a touched pixel in any of the 4 directions (not diagonally). 441 // a touched pixel in any of the 4 directions (not diagonally).
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 ClipRect(solid_part); 572 ClipRect(solid_part);
575 DrawStringInt(text, font, color, 573 DrawStringInt(text, font, color,
576 text_rect.x(), text_rect.y(), 574 text_rect.x(), text_rect.y(),
577 text_rect.width(), text_rect.height(), 575 text_rect.width(), text_rect.height(),
578 flags); 576 flags);
579 canvas_->restore(); 577 canvas_->restore();
580 canvas_->restore(); 578 canvas_->restore();
581 } 579 }
582 580
583 } // namespace gfx 581 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/canvas_skia.cc ('k') | ui/gfx/render_text.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698