OLD | NEW |
---|---|
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 Loading... | |
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 CanvasSkia text_canvas(w + 2, h + 2, true); | 418 CanvasSkia text_canvas(w + 2, h + 2, true); |
Peter Kasting
2011/11/05 01:10:10
Nit: We could probably create a rect with this siz
tfarina
2011/11/05 02:23:24
Done.
| |
419 SkPaint bkgnd_paint; | 419 SkPaint bkgnd_paint; |
420 bkgnd_paint.setColor(halo_color); | 420 bkgnd_paint.setColor(halo_color); |
421 text_canvas.DrawRectInt(0, 0, w + 2, h + 2, bkgnd_paint); | 421 text_canvas.DrawRect(gfx::Rect(0, 0, w + 2, h + 2), bkgnd_paint); |
422 | 422 |
423 // Draw the text into the temporary buffer. This will have correct | 423 // Draw the text into the temporary buffer. This will have correct |
424 // 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. |
425 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); |
426 | 426 |
427 // 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 |
428 // 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 |
429 // 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 |
430 // Windows draw will look transparent to it! | 430 // Windows draw will look transparent to it! |
431 skia::MakeOpaque(text_canvas.sk_canvas(), 0, 0, w + 2, h + 2); | 431 skia::MakeOpaque(text_canvas.sk_canvas(), 0, 0, w + 2, h + 2); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
572 ClipRect(solid_part); | 572 ClipRect(solid_part); |
573 DrawStringInt(text, font, color, | 573 DrawStringInt(text, font, color, |
574 text_rect.x(), text_rect.y(), | 574 text_rect.x(), text_rect.y(), |
575 text_rect.width(), text_rect.height(), | 575 text_rect.width(), text_rect.height(), |
576 flags); | 576 flags); |
577 canvas_->restore(); | 577 canvas_->restore(); |
578 canvas_->restore(); | 578 canvas_->restore(); |
579 } | 579 } |
580 | 580 |
581 } // namespace gfx | 581 } // namespace gfx |
OLD | NEW |