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

Side by Side Diff: Source/core/html/canvas/WebGLRenderingContextBase.h

Issue 163773007: WebGL: Transfer ownership of WebGraphicsContext3D from WebGLRenderingContext to DrawingBuffer. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@correct_webgl_destroy
Patch Set: Rebase to upstream Created 6 years, 9 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
OLDNEW
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 16 matching lines...) Expand all
27 #define WebGLRenderingContextBase_h 27 #define WebGLRenderingContextBase_h
28 28
29 #include "core/dom/ActiveDOMObject.h" 29 #include "core/dom/ActiveDOMObject.h"
30 #include "core/html/canvas/CanvasRenderingContext.h" 30 #include "core/html/canvas/CanvasRenderingContext.h"
31 #include "core/html/canvas/WebGLExtensionName.h" 31 #include "core/html/canvas/WebGLExtensionName.h"
32 #include "core/html/canvas/WebGLGetInfo.h" 32 #include "core/html/canvas/WebGLGetInfo.h"
33 #include "core/page/Page.h" 33 #include "core/page/Page.h"
34 #include "platform/Timer.h" 34 #include "platform/Timer.h"
35 #include "platform/graphics/GraphicsTypes3D.h" 35 #include "platform/graphics/GraphicsTypes3D.h"
36 #include "platform/graphics/ImageBuffer.h" 36 #include "platform/graphics/ImageBuffer.h"
37 #include "platform/graphics/gpu/DrawingBuffer.h"
37 #include "platform/graphics/gpu/Extensions3DUtil.h" 38 #include "platform/graphics/gpu/Extensions3DUtil.h"
38 #include "platform/graphics/gpu/WebGLImageConversion.h" 39 #include "platform/graphics/gpu/WebGLImageConversion.h"
39 #include "public/platform/WebGraphicsContext3D.h" 40 #include "public/platform/WebGraphicsContext3D.h"
40 #include "wtf/Float32Array.h" 41 #include "wtf/Float32Array.h"
41 #include "wtf/Int32Array.h" 42 #include "wtf/Int32Array.h"
42 #include "wtf/OwnPtr.h" 43 #include "wtf/OwnPtr.h"
43 #include "wtf/text/WTFString.h" 44 #include "wtf/text/WTFString.h"
44 45
45 namespace blink { 46 namespace blink {
46 class WebLayer; 47 class WebLayer;
47 } 48 }
48 49
49 namespace WebCore { 50 namespace WebCore {
50 51
51 class ANGLEInstancedArrays; 52 class ANGLEInstancedArrays;
52 class DrawingBuffer;
53 class EXTFragDepth; 53 class EXTFragDepth;
54 class EXTTextureFilterAnisotropic; 54 class EXTTextureFilterAnisotropic;
55 class ExceptionState; 55 class ExceptionState;
56 class HTMLImageElement; 56 class HTMLImageElement;
57 class HTMLVideoElement; 57 class HTMLVideoElement;
58 class ImageBuffer; 58 class ImageBuffer;
59 class ImageData; 59 class ImageData;
60 class IntSize; 60 class IntSize;
61 class OESElementIndexUint; 61 class OESElementIndexUint;
62 class OESStandardDerivatives; 62 class OESStandardDerivatives;
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 String getShaderSource(WebGLShader*); 197 String getShaderSource(WebGLShader*);
198 Vector<String> getSupportedExtensions(); 198 Vector<String> getSupportedExtensions();
199 WebGLGetInfo getTexParameter(GLenum target, GLenum pname); 199 WebGLGetInfo getTexParameter(GLenum target, GLenum pname);
200 WebGLGetInfo getUniform(WebGLProgram*, const WebGLUniformLocation*); 200 WebGLGetInfo getUniform(WebGLProgram*, const WebGLUniformLocation*);
201 PassRefPtr<WebGLUniformLocation> getUniformLocation(WebGLProgram*, const Str ing&); 201 PassRefPtr<WebGLUniformLocation> getUniformLocation(WebGLProgram*, const Str ing&);
202 WebGLGetInfo getVertexAttrib(GLuint index, GLenum pname); 202 WebGLGetInfo getVertexAttrib(GLuint index, GLenum pname);
203 long long getVertexAttribOffset(GLuint index, GLenum pname); 203 long long getVertexAttribOffset(GLuint index, GLenum pname);
204 204
205 void hint(GLenum target, GLenum mode); 205 void hint(GLenum target, GLenum mode);
206 GLboolean isBuffer(WebGLBuffer*); 206 GLboolean isBuffer(WebGLBuffer*);
207 bool isContextLost(); 207 bool isContextLost() const;
208 GLboolean isEnabled(GLenum cap); 208 GLboolean isEnabled(GLenum cap);
209 GLboolean isFramebuffer(WebGLFramebuffer*); 209 GLboolean isFramebuffer(WebGLFramebuffer*);
210 GLboolean isProgram(WebGLProgram*); 210 GLboolean isProgram(WebGLProgram*);
211 GLboolean isRenderbuffer(WebGLRenderbuffer*); 211 GLboolean isRenderbuffer(WebGLRenderbuffer*);
212 GLboolean isShader(WebGLShader*); 212 GLboolean isShader(WebGLShader*);
213 GLboolean isTexture(WebGLTexture*); 213 GLboolean isTexture(WebGLTexture*);
214 214
215 void lineWidth(GLfloat); 215 void lineWidth(GLfloat);
216 void linkProgram(WebGLProgram*); 216 void linkProgram(WebGLProgram*);
217 void pixelStorei(GLenum pname, GLint param); 217 void pixelStorei(GLenum pname, GLint param);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 // Lost context provoked by WEBKIT_lose_context. 316 // Lost context provoked by WEBKIT_lose_context.
317 SyntheticLostContext, 317 SyntheticLostContext,
318 318
319 // A synthetic lost context that should attempt to recover automatically 319 // A synthetic lost context that should attempt to recover automatically
320 AutoRecoverSyntheticLostContext 320 AutoRecoverSyntheticLostContext
321 }; 321 };
322 void forceLostContext(LostContextMode); 322 void forceLostContext(LostContextMode);
323 void forceRestoreContext(); 323 void forceRestoreContext();
324 void loseContextImpl(LostContextMode); 324 void loseContextImpl(LostContextMode);
325 325
326 blink::WebGraphicsContext3D* webGraphicsContext3D() const { return m_context .get(); } 326 blink::WebGraphicsContext3D* webContext() const { return m_drawingBuffer->co ntext(); }
327 WebGLContextGroup* contextGroup() const { return m_contextGroup.get(); } 327 WebGLContextGroup* contextGroup() const { return m_contextGroup.get(); }
328 virtual blink::WebLayer* platformLayer() const OVERRIDE; 328 virtual blink::WebLayer* platformLayer() const OVERRIDE;
329 Extensions3DUtil* extensionsUtil(); 329 Extensions3DUtil* extensionsUtil();
330 330
331 void reshape(int width, int height); 331 void reshape(int width, int height);
332 332
333 void markLayerComposited(); 333 void markLayerComposited();
334 virtual void paintRenderingResultsToCanvas() OVERRIDE; 334 virtual void paintRenderingResultsToCanvas() OVERRIDE;
335 PassRefPtr<ImageData> paintRenderingResultsToImageData(); 335 PassRefPtr<ImageData> paintRenderingResultsToImageData();
336 336
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 // Adds a compressed texture format. 383 // Adds a compressed texture format.
384 void addCompressedTextureFormat(GLenum); 384 void addCompressedTextureFormat(GLenum);
385 void removeAllCompressedTextureFormats(); 385 void removeAllCompressedTextureFormats();
386 386
387 PassRefPtr<Image> drawImageIntoBuffer(Image*, int width, int height); 387 PassRefPtr<Image> drawImageIntoBuffer(Image*, int width, int height);
388 388
389 PassRefPtr<Image> videoFrameToImage(HTMLVideoElement*, BackingStoreCopy); 389 PassRefPtr<Image> videoFrameToImage(HTMLVideoElement*, BackingStoreCopy);
390 390
391 WebGLRenderbuffer* ensureEmulatedStencilBuffer(GLenum target, WebGLRenderbuf fer*); 391 WebGLRenderbuffer* ensureEmulatedStencilBuffer(GLenum target, WebGLRenderbuf fer*);
392 392
393 OwnPtr<blink::WebGraphicsContext3D> m_context;
394 RefPtr<WebGLContextGroup> m_contextGroup;
395
396 // Structure for rendering to a DrawingBuffer, instead of directly 393 // Structure for rendering to a DrawingBuffer, instead of directly
397 // to the back-buffer of m_context. 394 // to the back-buffer of m_context.
398 RefPtr<DrawingBuffer> m_drawingBuffer; 395 RefPtr<DrawingBuffer> m_drawingBuffer;
396 RefPtr<WebGLContextGroup> m_contextGroup;
399 397
400 // Dispatches a context lost event once it is determined that one is needed. 398 // Dispatches a context lost event once it is determined that one is needed.
401 // This is used both for synthetic and real context losses. For real ones, i t's 399 // This is used both for synthetic and real context losses. For real ones, i t's
402 // likely that there's no JavaScript on the stack, but that might be depende nt 400 // likely that there's no JavaScript on the stack, but that might be depende nt
403 // on how exactly the platform discovers that the context was lost. For bett er 401 // on how exactly the platform discovers that the context was lost. For bett er
404 // portability we always defer the dispatch of the event. 402 // portability we always defer the dispatch of the event.
405 Timer<WebGLRenderingContextBase> m_dispatchContextLostEventTimer; 403 Timer<WebGLRenderingContextBase> m_dispatchContextLostEventTimer;
406 bool m_restoreAllowed; 404 bool m_restoreAllowed;
407 Timer<WebGLRenderingContextBase> m_restoreTimer; 405 Timer<WebGLRenderingContextBase> m_restoreTimer;
408 406
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 // If the vector is empty, return the maximum allowed active context number. 912 // If the vector is empty, return the maximum allowed active context number.
915 static size_t oldestContextIndex(); 913 static size_t oldestContextIndex();
916 static IntSize oldestContextSize(); 914 static IntSize oldestContextSize();
917 }; 915 };
918 916
919 DEFINE_TYPE_CASTS(WebGLRenderingContextBase, CanvasRenderingContext, context, co ntext->is3d(), context.is3d()); 917 DEFINE_TYPE_CASTS(WebGLRenderingContextBase, CanvasRenderingContext, context, co ntext->is3d(), context.is3d());
920 918
921 } // namespace WebCore 919 } // namespace WebCore
922 920
923 #endif // WebGLRenderingContextBase_h 921 #endif // WebGLRenderingContextBase_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698