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

Side by Side Diff: webrtc/test/mac/video_renderer_mac.mm

Issue 2834273002: Reland of GN: Enable ARC for Mac and iOS in rtc_* templates (Closed)
Patch Set: Make sure PeerConnection is released before factory Created 3 years, 8 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
« no previous file with comments | « webrtc/test/mac/run_test.mm ('k') | webrtc/webrtc.gni » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 25 matching lines...) Expand all
36 36
37 - (id)initWithTitle:(NSString *)title width:(int)width height:(int)height { 37 - (id)initWithTitle:(NSString *)title width:(int)width height:(int)height {
38 if (self = [super init]) { 38 if (self = [super init]) {
39 title_ = title; 39 title_ = title;
40 width_ = width; 40 width_ = width;
41 height_ = height; 41 height_ = height;
42 } 42 }
43 return self; 43 return self;
44 } 44 }
45 45
46 - (void)dealloc {
47 [window_ release];
48 [super dealloc];
49 }
50
51 - (void)createWindow:(NSObject *)ignored { 46 - (void)createWindow:(NSObject *)ignored {
52 NSInteger xOrigin = nextXOrigin_; 47 NSInteger xOrigin = nextXOrigin_;
53 NSRect screenFrame = [[NSScreen mainScreen] frame]; 48 NSRect screenFrame = [[NSScreen mainScreen] frame];
54 if (nextXOrigin_ + width_ < screenFrame.size.width) { 49 if (nextXOrigin_ + width_ < screenFrame.size.width) {
55 nextXOrigin_ += width_; 50 nextXOrigin_ += width_;
56 } else { 51 } else {
57 xOrigin = 0; 52 xOrigin = 0;
58 nextXOrigin_ = 0; 53 nextXOrigin_ = 0;
59 nextYOrigin_ += height_; 54 nextYOrigin_ += height_;
60 } 55 }
61 if (nextYOrigin_ + height_ > screenFrame.size.height) { 56 if (nextYOrigin_ + height_ > screenFrame.size.height) {
62 xOrigin = 0; 57 xOrigin = 0;
63 nextXOrigin_ = 0; 58 nextXOrigin_ = 0;
64 nextYOrigin_ = 0; 59 nextYOrigin_ = 0;
65 } 60 }
66 NSInteger yOrigin = nextYOrigin_; 61 NSInteger yOrigin = nextYOrigin_;
67 NSRect windowFrame = NSMakeRect(xOrigin, yOrigin, width_, height_); 62 NSRect windowFrame = NSMakeRect(xOrigin, yOrigin, width_, height_);
68 window_ = [[NSWindow alloc] initWithContentRect:windowFrame 63 window_ = [[NSWindow alloc] initWithContentRect:windowFrame
69 styleMask:NSTitledWindowMask 64 styleMask:NSTitledWindowMask
70 backing:NSBackingStoreBuffered 65 backing:NSBackingStoreBuffered
71 defer:NO]; 66 defer:NO];
72 67
73 NSRect viewFrame = NSMakeRect(0, 0, width_, height_); 68 NSRect viewFrame = NSMakeRect(0, 0, width_, height_);
74 NSOpenGLView *view = [[[NSOpenGLView alloc] initWithFrame:viewFrame 69 NSOpenGLView *view = [[NSOpenGLView alloc] initWithFrame:viewFrame pixelFormat :nil];
75 pixelFormat:nil] autorelease];
76 context_ = [view openGLContext]; 70 context_ = [view openGLContext];
77 71
78 [[window_ contentView] addSubview:view]; 72 [[window_ contentView] addSubview:view];
79 [window_ setTitle:title_]; 73 [window_ setTitle:title_];
80 [window_ makeKeyAndOrderFront:NSApp]; 74 [window_ makeKeyAndOrderFront:NSApp];
81 } 75 }
82 76
83 - (void)makeCurrentContext { 77 - (void)makeCurrentContext {
84 [context_ makeCurrentContext]; 78 [context_ makeCurrentContext];
85 } 79 }
(...skipping 12 matching lines...) Expand all
98 return NULL; 92 return NULL;
99 } 93 }
100 return renderer; 94 return renderer;
101 } 95 }
102 96
103 MacRenderer::MacRenderer() 97 MacRenderer::MacRenderer()
104 : window_(NULL) {} 98 : window_(NULL) {}
105 99
106 MacRenderer::~MacRenderer() { 100 MacRenderer::~MacRenderer() {
107 GlRenderer::Destroy(); 101 GlRenderer::Destroy();
108 [window_ release];
109 } 102 }
110 103
111 bool MacRenderer::Init(const char* window_title, int width, int height) { 104 bool MacRenderer::Init(const char* window_title, int width, int height) {
112 window_ = [[CocoaWindow alloc] 105 window_ = [[CocoaWindow alloc]
113 initWithTitle:[NSString stringWithUTF8String:window_title] 106 initWithTitle:[NSString stringWithUTF8String:window_title]
114 width:width 107 width:width
115 height:height]; 108 height:height];
116 if (!window_) 109 if (!window_)
117 return false; 110 return false;
118 [window_ performSelectorOnMainThread:@selector(createWindow:) 111 [window_ performSelectorOnMainThread:@selector(createWindow:)
119 withObject:nil 112 withObject:nil
120 waitUntilDone:YES]; 113 waitUntilDone:YES];
121 114
122 [window_ makeCurrentContext]; 115 [window_ makeCurrentContext];
123 GlRenderer::Init(); 116 GlRenderer::Init();
124 GlRenderer::ResizeViewport(width, height); 117 GlRenderer::ResizeViewport(width, height);
125 return true; 118 return true;
126 } 119 }
127 120
128 void MacRenderer::OnFrame(const VideoFrame& frame) { 121 void MacRenderer::OnFrame(const VideoFrame& frame) {
129 [window_ makeCurrentContext]; 122 [window_ makeCurrentContext];
130 GlRenderer::OnFrame(frame); 123 GlRenderer::OnFrame(frame);
131 } 124 }
132 125
133 } // test 126 } // test
134 } // webrtc 127 } // webrtc
OLDNEW
« no previous file with comments | « webrtc/test/mac/run_test.mm ('k') | webrtc/webrtc.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698