| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "remoting/host/mac/scoped_pixel_buffer_object.h" |
| 6 |
| 7 namespace remoting { |
| 8 |
| 9 ScopedPixelBufferObject::ScopedPixelBufferObject() |
| 10 : cgl_context_(NULL), |
| 11 pixel_buffer_object_(0) { |
| 12 } |
| 13 |
| 14 ScopedPixelBufferObject::~ScopedPixelBufferObject() { |
| 15 Release(); |
| 16 } |
| 17 |
| 18 bool ScopedPixelBufferObject::Init(CGLContextObj cgl_context, |
| 19 int size_in_bytes) { |
| 20 cgl_context_ = cgl_context; |
| 21 CGLContextObj CGL_MACRO_CONTEXT = cgl_context_; |
| 22 glGenBuffersARB(1, &pixel_buffer_object_); |
| 23 if (glGetError() == GL_NO_ERROR) { |
| 24 glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pixel_buffer_object_); |
| 25 glBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, size_in_bytes, NULL, |
| 26 GL_STREAM_READ_ARB); |
| 27 glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0); |
| 28 if (glGetError() != GL_NO_ERROR) { |
| 29 Release(); |
| 30 } |
| 31 } else { |
| 32 cgl_context_ = NULL; |
| 33 pixel_buffer_object_ = 0; |
| 34 } |
| 35 return pixel_buffer_object_ != 0; |
| 36 } |
| 37 |
| 38 void ScopedPixelBufferObject::Release() { |
| 39 if (pixel_buffer_object_) { |
| 40 CGLContextObj CGL_MACRO_CONTEXT = cgl_context_; |
| 41 glDeleteBuffersARB(1, &pixel_buffer_object_); |
| 42 cgl_context_ = NULL; |
| 43 pixel_buffer_object_ = 0; |
| 44 } |
| 45 } |
| 46 |
| 47 } // namespace remoting |
| OLD | NEW |