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

Side by Side Diff: Source/platform/graphics/gpu/DrawingBuffer.h

Issue 169933002: WebGL: Don't destroy mailbox textures in the destructor until they're released. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix crash Created 6 years, 8 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) 2010, Google Inc. All rights reserved. 2 * Copyright (c) 2010, Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 virtual IntSize oldestContextSize() = 0; 65 virtual IntSize oldestContextSize() = 0;
66 }; 66 };
67 67
68 // Manages a rendering target (framebuffer + attachment) for a canvas. Can publ ish its rendering 68 // Manages a rendering target (framebuffer + attachment) for a canvas. Can publ ish its rendering
69 // results to a blink::WebLayer for compositing. 69 // results to a blink::WebLayer for compositing.
70 class PLATFORM_EXPORT DrawingBuffer : public RefCounted<DrawingBuffer>, public b link::WebExternalTextureLayerClient { 70 class PLATFORM_EXPORT DrawingBuffer : public RefCounted<DrawingBuffer>, public b link::WebExternalTextureLayerClient {
71 struct MailboxInfo : public RefCounted<MailboxInfo> { 71 struct MailboxInfo : public RefCounted<MailboxInfo> {
72 blink::WebExternalTextureMailbox mailbox; 72 blink::WebExternalTextureMailbox mailbox;
73 unsigned textureId; 73 unsigned textureId;
74 IntSize size; 74 IntSize size;
75 RefPtr<DrawingBuffer> m_parentDrawingBuffer;
Ken Russell (switch to Gerrit) 2014/04/15 02:24:02 Please document the semantics. "This keeps the pa
75 }; 76 };
76 public: 77 public:
77 enum PreserveDrawingBuffer { 78 enum PreserveDrawingBuffer {
78 Preserve, 79 Preserve,
79 Discard 80 Discard
80 }; 81 };
81 82
82 static PassRefPtr<DrawingBuffer> create(PassOwnPtr<blink::WebGraphicsContext 3D>, const IntSize&, PreserveDrawingBuffer, PassRefPtr<ContextEvictionManager>); 83 static PassRefPtr<DrawingBuffer> create(PassOwnPtr<blink::WebGraphicsContext 3D>, const IntSize&, PreserveDrawingBuffer, PassRefPtr<ContextEvictionManager>);
83 84
84 virtual ~DrawingBuffer(); 85 virtual ~DrawingBuffer();
85 86
87 // Destruction will be completed after all mailboxes are received.
Ken Russell (switch to Gerrit) 2014/04/15 02:24:02 received -> released
88 void beginDestruction();
89
86 // Issues a glClear() on all framebuffers associated with this DrawingBuffer . The caller is responsible for 90 // Issues a glClear() on all framebuffers associated with this DrawingBuffer . The caller is responsible for
87 // making the context current and setting the clear values and masks. Modifi es the framebuffer binding. 91 // making the context current and setting the clear values and masks. Modifi es the framebuffer binding.
88 void clearFramebuffers(GLbitfield clearMask); 92 void clearFramebuffers(GLbitfield clearMask);
89 93
90 // Given the desired buffer size, provides the largest dimensions that will fit in the pixel budget. 94 // Given the desired buffer size, provides the largest dimensions that will fit in the pixel budget.
91 IntSize adjustSize(const IntSize&); 95 IntSize adjustSize(const IntSize&);
92 bool reset(const IntSize&); 96 bool reset(const IntSize&);
93 void bind(); 97 void bind();
94 IntSize size() const { return m_size; } 98 IntSize size() const { return m_size; }
95 99
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 135
132 // Destroys the TEXTURE_2D binding for the owned context 136 // Destroys the TEXTURE_2D binding for the owned context
133 bool copyToPlatformTexture(blink::WebGraphicsContext3D*, Platform3DObject te xture, GLenum internalFormat, 137 bool copyToPlatformTexture(blink::WebGraphicsContext3D*, Platform3DObject te xture, GLenum internalFormat,
134 GLenum destType, GLint level, bool premultiplyAlpha, bool flipY); 138 GLenum destType, GLint level, bool premultiplyAlpha, bool flipY);
135 139
136 void setPackAlignment(GLint param); 140 void setPackAlignment(GLint param);
137 141
138 void paintRenderingResultsToCanvas(ImageBuffer*); 142 void paintRenderingResultsToCanvas(ImageBuffer*);
139 PassRefPtr<Uint8ClampedArray> paintRenderingResultsToImageData(int&, int&); 143 PassRefPtr<Uint8ClampedArray> paintRenderingResultsToImageData(int&, int&);
140 144
141 private: 145 protected: // For unittests
142 DrawingBuffer(PassOwnPtr<blink::WebGraphicsContext3D>, bool multisampleExten sionSupported, 146 DrawingBuffer(PassOwnPtr<blink::WebGraphicsContext3D>, bool multisampleExten sionSupported,
143 bool packedDepthStencilExtensionSupported, PreserveDrawingBuff er, PassRefPtr<ContextEvictionManager>); 147 bool packedDepthStencilExtensionSupported, PreserveDrawingBuff er, PassRefPtr<ContextEvictionManager>);
144 148
145 bool initialize(const IntSize&); 149 bool initialize(const IntSize&);
146 void releaseResources(); 150
151 private:
152 void mailboxReleasedInDestructionInProgress(const blink::WebExternalTextureM ailbox&);
Ken Russell (switch to Gerrit) 2014/04/15 02:24:02 Please rename this to "mailboxReleasedWhileDestruc
147 153
148 unsigned createColorTexture(const IntSize& size = IntSize()); 154 unsigned createColorTexture(const IntSize& size = IntSize());
149 // Create the depth/stencil and multisample buffers, if needed. 155 // Create the depth/stencil and multisample buffers, if needed.
150 void createSecondaryBuffers(); 156 void createSecondaryBuffers();
151 bool resizeFramebuffer(const IntSize&); 157 bool resizeFramebuffer(const IntSize&);
152 bool resizeMultisampleFramebuffer(const IntSize&); 158 bool resizeMultisampleFramebuffer(const IntSize&);
153 void resizeDepthStencil(const IntSize&); 159 void resizeDepthStencil(const IntSize&);
154 160
155 // Bind to the m_framebufferBinding if it's not 0. 161 // Bind to the m_framebufferBinding if it's not 0.
156 void restoreFramebufferBinding(); 162 void restoreFramebufferBinding();
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 236
231 MultisampleMode m_multisampleMode; 237 MultisampleMode m_multisampleMode;
232 238
233 blink::WebGraphicsContext3D::Attributes m_attributes; 239 blink::WebGraphicsContext3D::Attributes m_attributes;
234 unsigned m_internalColorFormat; 240 unsigned m_internalColorFormat;
235 unsigned m_colorFormat; 241 unsigned m_colorFormat;
236 unsigned m_internalRenderbufferFormat; 242 unsigned m_internalRenderbufferFormat;
237 int m_maxTextureSize; 243 int m_maxTextureSize;
238 int m_sampleCount; 244 int m_sampleCount;
239 int m_packAlignment; 245 int m_packAlignment;
246 bool m_destructionInProgress;
240 247
241 OwnPtr<blink::WebExternalTextureLayer> m_layer; 248 OwnPtr<blink::WebExternalTextureLayer> m_layer;
242 249
243 // All of the mailboxes that this DrawingBuffer has ever created. 250 // All of the mailboxes that this DrawingBuffer has ever created.
244 Vector<RefPtr<MailboxInfo> > m_textureMailboxes; 251 Vector<RefPtr<MailboxInfo> > m_textureMailboxes;
245 // Mailboxes that were released by the compositor and can be used again by t his DrawingBuffer. 252 // Mailboxes that were released by the compositor and can be used again by t his DrawingBuffer.
246 Vector<RefPtr<MailboxInfo> > m_recycledMailboxes; 253 Vector<RefPtr<MailboxInfo> > m_recycledMailboxes;
247 254
248 RefPtr<ContextEvictionManager> m_contextEvictionManager; 255 RefPtr<ContextEvictionManager> m_contextEvictionManager;
249 256
250 // If the width and height of the Canvas's backing store don't 257 // If the width and height of the Canvas's backing store don't
251 // match those that we were given in the most recent call to 258 // match those that we were given in the most recent call to
252 // reshape(), then we need an intermediate bitmap to read back the 259 // reshape(), then we need an intermediate bitmap to read back the
253 // frame buffer into. This seems to happen when CSS styles are 260 // frame buffer into. This seems to happen when CSS styles are
254 // used to resize the Canvas. 261 // used to resize the Canvas.
255 SkBitmap m_resizingBitmap; 262 SkBitmap m_resizingBitmap;
256 263
257 // Used to flip a bitmap vertically. 264 // Used to flip a bitmap vertically.
258 Vector<uint8_t> m_scanline; 265 Vector<uint8_t> m_scanline;
259 }; 266 };
260 267
261 } // namespace WebCore 268 } // namespace WebCore
262 269
263 #endif // DrawingBuffer_h 270 #endif // DrawingBuffer_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698