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

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

Issue 9416017: Optionally clear PlatformCanvas instances. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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 | Annotate | Revision Log
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 "ui/gfx/canvas.h" 5 #include "ui/gfx/canvas.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 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 544
545 // Grow |display_rect| by |offset_x|. 545 // Grow |display_rect| by |offset_x|.
546 gfx::Rect text_rect(gfx::Point(), display_rect.size()); 546 gfx::Rect text_rect(gfx::Point(), display_rect.size());
547 if (!is_rtl) 547 if (!is_rtl)
548 text_rect.set_x(text_rect.x() - offset_x); 548 text_rect.set_x(text_rect.x() - offset_x);
549 text_rect.set_width(text_rect.width() + offset_x); 549 text_rect.set_width(text_rect.width() + offset_x);
550 550
551 // Create a temporary bitmap to draw the gradient to. 551 // Create a temporary bitmap to draw the gradient to.
552 scoped_ptr<SkCanvas> gradient_canvas(skia::CreateBitmapCanvas( 552 scoped_ptr<SkCanvas> gradient_canvas(skia::CreateBitmapCanvas(
553 display_rect.width(), display_rect.height(), false)); 553 display_rect.width(), display_rect.height(), false));
554 gradient_canvas->clear(SkColorSetARGB(0, 0, 0, 0));
msw 2012/03/15 21:53:07 Is this needed by other direct SkCanvas users too?
Jeff Timanus 2012/03/15 22:26:53 I searched through all users of SkCanvas (and asso
554 555
555 { 556 {
556 skia::ScopedPlatformPaint scoped_platform_paint(canvas_); 557 skia::ScopedPlatformPaint scoped_platform_paint(canvas_);
557 HDC hdc = scoped_platform_paint.GetPlatformSurface(); 558 HDC hdc = scoped_platform_paint.GetPlatformSurface();
558 if (is_truncating_head) 559 if (is_truncating_head)
559 DrawTextGradientPart(hdc, gradient_canvas.get(), text, color, 560 DrawTextGradientPart(hdc, gradient_canvas.get(), text, color,
560 font.GetNativeFont(), text_rect, head_part, is_rtl, 561 font.GetNativeFont(), text_rect, head_part, is_rtl,
561 flags); 562 flags);
562 if (is_truncating_tail) 563 if (is_truncating_tail)
563 DrawTextGradientPart(hdc, gradient_canvas.get(), text, color, 564 DrawTextGradientPart(hdc, gradient_canvas.get(), text, color,
564 font.GetNativeFont(), text_rect, tail_part, !is_rtl, 565 font.GetNativeFont(), text_rect, tail_part, !is_rtl,
565 flags); 566 flags);
566 } 567 }
567 568
568 // Draw the solid part. 569 // Draw the solid part.
569 canvas_->save(SkCanvas::kClip_SaveFlag); 570 canvas_->save(SkCanvas::kClip_SaveFlag);
570 ClipRect(solid_part); 571 ClipRect(solid_part);
571 DrawStringInt(text, font, color, 572 DrawStringInt(text, font, color,
572 text_rect.x(), text_rect.y(), 573 text_rect.x(), text_rect.y(),
573 text_rect.width(), text_rect.height(), 574 text_rect.width(), text_rect.height(),
574 flags); 575 flags);
575 canvas_->restore(); 576 canvas_->restore();
576 canvas_->restore(); 577 canvas_->restore();
577 } 578 }
578 579
579 } // namespace gfx 580 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698