Chromium Code Reviews| Index: chrome/browser/ui/cocoa/tabs/tab_audio_indicator_view_mac.mm |
| diff --git a/chrome/browser/ui/cocoa/tabs/tab_audio_indicator_view_mac.mm b/chrome/browser/ui/cocoa/tabs/tab_audio_indicator_view_mac.mm |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..84b222014e3e572bd1ce807e83d2f6e56a4d4aef |
| --- /dev/null |
| +++ b/chrome/browser/ui/cocoa/tabs/tab_audio_indicator_view_mac.mm |
| @@ -0,0 +1,63 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#import "chrome/browser/ui/cocoa/tabs/tab_audio_indicator_view_mac.h" |
| + |
| +#include "chrome/browser/ui/tabs/tab_audio_indicator.h" |
| +#include "ui/gfx/canvas_skia_paint.h" |
| +#include "ui/gfx/rect.h" |
| + |
| +class TabAudioIndicatorDelegateMac : public TabAudioIndicator::Delegate { |
| + public: |
| + TabAudioIndicatorDelegateMac(TabAudioIndicatorViewMac* view) : view_(view) {} |
|
Nico
2013/03/11 02:52:56
1-element constructors should be marked explicit
sail
2013/03/11 23:42:01
Done.
|
| + |
| + virtual ~TabAudioIndicatorDelegateMac() {} |
| + |
| + virtual void ScheduleAudioIndicatorPaint() OVERRIDE { |
| + [view_ setNeedsDisplay:YES]; |
| + } |
| + |
| + private: |
| + TabAudioIndicatorViewMac* view_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(TabAudioIndicatorDelegateMac); |
| +}; |
| + |
| +@interface TabAudioIndicatorViewMac () |
| +@end |
| + |
| +@implementation TabAudioIndicatorViewMac |
| + |
| +- (id)initWithFrame:(NSRect)frame { |
| + if ((self = [super initWithFrame:frame])) { |
| + delegate_.reset(new TabAudioIndicatorDelegateMac(self)); |
| + tabAudioIndicator_.reset(new TabAudioIndicator(delegate_.get())); |
| + } |
| + return self; |
| +} |
| + |
| +- (void)setIsPlayingAudio:(BOOL)isPlayingAudio { |
| + tabAudioIndicator_->SetIsPlayingAudio(isPlayingAudio); |
| +} |
| + |
| +- (void)setBackgroundImage:(NSImage*)backgroundImage { |
| + backgroundImage_.reset([backgroundImage retain]); |
| +} |
| + |
| +- (BOOL)isAnimating { |
| + return tabAudioIndicator_->IsAnimating(); |
| +} |
| + |
| +- (void)drawRect:(NSRect)rect { |
| + [backgroundImage_ drawInRect:[self bounds] |
| + fromRect:NSZeroRect |
| + operation:NSCompositeSourceOver |
| + fraction:1]; |
| + |
| + gfx::CanvasSkiaPaint canvas(rect, false); |
|
Nico
2013/03/11 02:52:56
Hm, CanvasSkiaPaint requires allocating a skia bac
sail
2013/03/11 23:42:01
Hm.. doesn't drawing a SkBitmap require copying to
Nico
2013/03/11 23:47:56
My reading of SkCreateCGImageRefWithColorspace() i
sail
2013/03/12 00:25:12
Hm... I think I'm doing something wrong.
The curre
|
| + canvas.set_composite_alpha(true); |
| + tabAudioIndicator_->Paint(&canvas, gfx::Rect(NSRectToCGRect([self bounds]))); |
| +} |
| + |
| +@end |