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

Side by Side Diff: chrome/browser/ui/cocoa/tabs/tab_audio_indicator_view_mac.mm

Issue 12648004: Audio indicator: Mac UI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 7 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
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #import "chrome/browser/ui/cocoa/tabs/tab_audio_indicator_view_mac.h"
6
7 #include "chrome/browser/ui/tabs/tab_audio_indicator.h"
8 #include "ui/gfx/canvas_skia_paint.h"
9 #include "ui/gfx/rect.h"
10
11 class TabAudioIndicatorDelegateMac : public TabAudioIndicator::Delegate {
12 public:
13 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.
14
15 virtual ~TabAudioIndicatorDelegateMac() {}
16
17 virtual void ScheduleAudioIndicatorPaint() OVERRIDE {
18 [view_ setNeedsDisplay:YES];
19 }
20
21 private:
22 TabAudioIndicatorViewMac* view_;
23
24 DISALLOW_COPY_AND_ASSIGN(TabAudioIndicatorDelegateMac);
25 };
26
27 @interface TabAudioIndicatorViewMac ()
28 @end
29
30 @implementation TabAudioIndicatorViewMac
31
32 - (id)initWithFrame:(NSRect)frame {
33 if ((self = [super initWithFrame:frame])) {
34 delegate_.reset(new TabAudioIndicatorDelegateMac(self));
35 tabAudioIndicator_.reset(new TabAudioIndicator(delegate_.get()));
36 }
37 return self;
38 }
39
40 - (void)setIsPlayingAudio:(BOOL)isPlayingAudio {
41 tabAudioIndicator_->SetIsPlayingAudio(isPlayingAudio);
42 }
43
44 - (void)setBackgroundImage:(NSImage*)backgroundImage {
45 backgroundImage_.reset([backgroundImage retain]);
46 }
47
48 - (BOOL)isAnimating {
49 return tabAudioIndicator_->IsAnimating();
50 }
51
52 - (void)drawRect:(NSRect)rect {
53 [backgroundImage_ drawInRect:[self bounds]
54 fromRect:NSZeroRect
55 operation:NSCompositeSourceOver
56 fraction:1];
57
58 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
59 canvas.set_composite_alpha(true);
60 tabAudioIndicator_->Paint(&canvas, gfx::Rect(NSRectToCGRect([self bounds])));
61 }
62
63 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698