| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 PassRefPtr<WebGLBuffer> WebGLBuffer::create(WebGLRenderingContext* ctx) | 37 PassRefPtr<WebGLBuffer> WebGLBuffer::create(WebGLRenderingContext* ctx) |
| 38 { | 38 { |
| 39 return adoptRef(new WebGLBuffer(ctx)); | 39 return adoptRef(new WebGLBuffer(ctx)); |
| 40 } | 40 } |
| 41 | 41 |
| 42 WebGLBuffer::WebGLBuffer(WebGLRenderingContext* ctx) | 42 WebGLBuffer::WebGLBuffer(WebGLRenderingContext* ctx) |
| 43 : WebGLSharedObject(ctx) | 43 : WebGLSharedObject(ctx) |
| 44 , m_target(0) | 44 , m_target(0) |
| 45 { | 45 { |
| 46 ScriptWrappable::init(this); |
| 46 setObject(ctx->graphicsContext3D()->createBuffer()); | 47 setObject(ctx->graphicsContext3D()->createBuffer()); |
| 47 } | 48 } |
| 48 | 49 |
| 49 WebGLBuffer::~WebGLBuffer() | 50 WebGLBuffer::~WebGLBuffer() |
| 50 { | 51 { |
| 51 deleteObject(0); | 52 deleteObject(0); |
| 52 } | 53 } |
| 53 | 54 |
| 54 void WebGLBuffer::deleteObjectImpl(GraphicsContext3D* context3d, Platform3DObjec
t object) | 55 void WebGLBuffer::deleteObjectImpl(GraphicsContext3D* context3d, Platform3DObjec
t object) |
| 55 { | 56 { |
| 56 context3d->deleteBuffer(object); | 57 context3d->deleteBuffer(object); |
| 57 } | 58 } |
| 58 | 59 |
| 59 void WebGLBuffer::setTarget(GC3Denum target) | 60 void WebGLBuffer::setTarget(GC3Denum target) |
| 60 { | 61 { |
| 61 // In WebGL, a buffer is bound to one target in its lifetime | 62 // In WebGL, a buffer is bound to one target in its lifetime |
| 62 if (m_target) | 63 if (m_target) |
| 63 return; | 64 return; |
| 64 if (target == GraphicsContext3D::ARRAY_BUFFER || target == GraphicsContext3D
::ELEMENT_ARRAY_BUFFER) | 65 if (target == GraphicsContext3D::ARRAY_BUFFER || target == GraphicsContext3D
::ELEMENT_ARRAY_BUFFER) |
| 65 m_target = target; | 66 m_target = target; |
| 66 } | 67 } |
| 67 | 68 |
| 68 } | 69 } |
| OLD | NEW |