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

Unified Diff: remoting/ios/ui/desktop_texture.mm

Issue 186733007: iOS Chromoting Client (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/ios/ui/desktop_texture.h ('k') | remoting/ios/ui/help_view_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/ios/ui/desktop_texture.mm
diff --git a/remoting/ios/ui/desktop_texture.mm b/remoting/ios/ui/desktop_texture.mm
new file mode 100644
index 0000000000000000000000000000000000000000..d806dee8d74e84feb4c78fb5a4a786e30aff6447
--- /dev/null
+++ b/remoting/ios/ui/desktop_texture.mm
@@ -0,0 +1,83 @@
+// Copyright 2014 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.
+
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
+#import "remoting/ios/ui/desktop_texture.h"
+
+@implementation DesktopTexture
+
+- (const webrtc::DesktopSize&)textureSize {
+ return _textureSize;
+}
+
+- (void)setTextureSize:(const webrtc::DesktopSize&)size {
+ if (!_textureSize.equals(size)) {
+ _textureSize.set(size.width(), size.height());
+ _needInitialize = true;
+ }
+}
+
+- (void)bindToEffect:(GLKEffectPropertyTexture*)effectProperty {
+ glGenTextures(1, &_textureId);
+ [Utility bindTextureForIOS:_textureId];
+
+ // This is the HOST Desktop layer, and each draw will always replace what is
+ // currently in the draw context
+ effectProperty.target = GLKTextureTarget2D;
+ effectProperty.name = _textureId;
+ effectProperty.envMode = GLKTextureEnvModeReplace;
+ effectProperty.enabled = GL_TRUE;
+
+ [Utility logGLErrorCode:@"DesktopTexture bindToTexture"];
+ // Release context
+ glBindTexture(GL_TEXTURE_2D, 0);
+}
+
+- (BOOL)needDraw {
+ return _needInitialize;
+}
+
+- (void)drawRegion:(GLRegion*)region rect:(CGRect)rect {
+ if (_textureSize.height() == 0 && _textureSize.width() == 0) {
+ return;
+ }
+
+ [Utility bindTextureForIOS:_textureId];
+
+ if (_needInitialize) {
+ glTexImage2D(GL_TEXTURE_2D,
+ 0,
+ GL_RGBA,
+ _textureSize.width(),
+ _textureSize.height(),
+ 0,
+ GL_RGBA,
+ GL_UNSIGNED_BYTE,
+ NULL);
+
+ [Utility logGLErrorCode:@"DesktopTexture initializeTextureSurfaceWithSize"];
+ _needInitialize = false;
+ }
+
+ [Utility drawSubRectToGLFromRectOfSize:_textureSize
+ subRect:webrtc::DesktopRect::MakeXYWH(
+ region->offset->x(),
+ region->offset->y(),
+ region->image->size().width(),
+ region->image->size().height())
+ data:region->image->data()];
+
+ [Utility logGLErrorCode:@"DesktopTexture drawRegion"];
+ // Release context
+ glBindTexture(GL_TEXTURE_2D, 0);
+}
+
+- (void)releaseTexture {
+ glDeleteTextures(1, &_textureId);
+}
+
+@end
« no previous file with comments | « remoting/ios/ui/desktop_texture.h ('k') | remoting/ios/ui/help_view_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698