| 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 17 matching lines...) Expand all  Loading... | 
|  28  |  28  | 
|  29 #include "bindings/core/v8/ScriptWrappable.h" |  29 #include "bindings/core/v8/ScriptWrappable.h" | 
|  30 #include "platform/graphics/GraphicsTypes3D.h" |  30 #include "platform/graphics/GraphicsTypes3D.h" | 
|  31 #include "platform/heap/Handle.h" |  31 #include "platform/heap/Handle.h" | 
|  32 #include "wtf/RefCounted.h" |  32 #include "wtf/RefCounted.h" | 
|  33  |  33  | 
|  34 namespace blink { |  34 namespace blink { | 
|  35 class WebGraphicsContext3D; |  35 class WebGraphicsContext3D; | 
|  36 } |  36 } | 
|  37  |  37  | 
 |  38 namespace gpu { | 
 |  39 namespace gles2 { | 
 |  40 class GLES2Interface; | 
 |  41 } | 
 |  42 } | 
 |  43  | 
|  38 namespace blink { |  44 namespace blink { | 
|  39  |  45  | 
|  40 class WebGLContextGroup; |  46 class WebGLContextGroup; | 
|  41 class WebGLRenderingContextBase; |  47 class WebGLRenderingContextBase; | 
|  42  |  48  | 
|  43 template <typename T> |  49 template <typename T> | 
|  44 Platform3DObject objectOrZero(const T* object) |  50 Platform3DObject objectOrZero(const T* object) | 
|  45 { |  51 { | 
|  46     return object ? object->object() : 0; |  52     return object ? object->object() : 0; | 
|  47 } |  53 } | 
|  48  |  54  | 
|  49 class WebGLObject : public GarbageCollectedFinalized<WebGLObject>, public Script
    Wrappable { |  55 class WebGLObject : public GarbageCollectedFinalized<WebGLObject>, public Script
    Wrappable { | 
|  50 public: |  56 public: | 
|  51     virtual ~WebGLObject(); |  57     virtual ~WebGLObject(); | 
|  52  |  58  | 
|  53     // deleteObject may not always delete the OpenGL resource.  For programs and |  59     // deleteObject may not always delete the OpenGL resource.  For programs and | 
|  54     // shaders, deletion is delayed until they are no longer attached. |  60     // shaders, deletion is delayed until they are no longer attached. | 
|  55     // FIXME: revisit this when resource sharing between contexts are implemente
    d. |  61     // FIXME: revisit this when resource sharing between contexts are implemente
    d. | 
|  56     void deleteObject(WebGraphicsContext3D*); |  62     void deleteObject(WebGraphicsContext3D*, gpu::gles2::GLES2Interface*); | 
|  57  |  63  | 
|  58     void onAttached() { ++m_attachmentCount; } |  64     void onAttached() { ++m_attachmentCount; } | 
|  59     void onDetached(WebGraphicsContext3D*); |  65     void onDetached(WebGraphicsContext3D*, gpu::gles2::GLES2Interface*); | 
|  60  |  66  | 
|  61     // This indicates whether the client side issue a delete call already, not |  67     // This indicates whether the client side issue a delete call already, not | 
|  62     // whether the OpenGL resource is deleted. |  68     // whether the OpenGL resource is deleted. | 
|  63     // object()==0 indicates the OpenGL resource is deleted. |  69     // object()==0 indicates the OpenGL resource is deleted. | 
|  64     bool isDeleted() { return m_deleted; } |  70     bool isDeleted() { return m_deleted; } | 
|  65  |  71  | 
|  66     // True if this object belongs to the group or context. |  72     // True if this object belongs to the group or context. | 
|  67     virtual bool validate(const WebGLContextGroup*, const WebGLRenderingContextB
    ase*) const = 0; |  73     virtual bool validate(const WebGLContextGroup*, const WebGLRenderingContextB
    ase*) const = 0; | 
|  68     virtual bool hasObject() const = 0; |  74     virtual bool hasObject() const = 0; | 
|  69  |  75  | 
|  70     DEFINE_INLINE_VIRTUAL_TRACE() { } |  76     DEFINE_INLINE_VIRTUAL_TRACE() { } | 
|  71  |  77  | 
|  72 protected: |  78 protected: | 
|  73     explicit WebGLObject(WebGLRenderingContextBase*); |  79     explicit WebGLObject(WebGLRenderingContextBase*); | 
|  74  |  80  | 
|  75     // deleteObjectImpl should be only called once to delete the OpenGL resource
    . |  81     // deleteObjectImpl should be only called once to delete the OpenGL resource
    . | 
|  76     // After calling deleteObjectImpl, hasObject() should return false. |  82     // After calling deleteObjectImpl, hasObject() should return false. | 
|  77     virtual void deleteObjectImpl(blink::WebGraphicsContext3D*) = 0; |  83     virtual void deleteObjectImpl(blink::WebGraphicsContext3D*, gpu::gles2::GLES
    2Interface*) = 0; | 
|  78  |  84  | 
|  79     virtual bool hasGroupOrContext() const = 0; |  85     virtual bool hasGroupOrContext() const = 0; | 
|  80  |  86  | 
|  81     void detach(); |  87     void detach(); | 
|  82     void detachAndDeleteObject(); |  88     void detachAndDeleteObject(); | 
|  83  |  89  | 
|  84     virtual WebGraphicsContext3D* getAWebGraphicsContext3D() const = 0; |  90     virtual WebGraphicsContext3D* getAWebGraphicsContext3D() const = 0; | 
|  85  |  91  | 
|  86 private: |  92 private: | 
|  87     unsigned m_attachmentCount; |  93     unsigned m_attachmentCount; | 
|  88     bool m_deleted; |  94     bool m_deleted; | 
|  89 }; |  95 }; | 
|  90  |  96  | 
|  91 } // namespace blink |  97 } // namespace blink | 
|  92  |  98  | 
|  93 #endif // WebGLObject_h |  99 #endif // WebGLObject_h | 
| OLD | NEW |