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

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

Issue 251023004: WebGL: Free temporary GPU resources held by inactive or hidden WebGL. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase to ToT 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) 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 class WebGLUniformLocation; 93 class WebGLUniformLocation;
94 class WebGLVertexArrayObjectOES; 94 class WebGLVertexArrayObjectOES;
95 95
96 class WebGLRenderingContextLostCallback; 96 class WebGLRenderingContextLostCallback;
97 class WebGLRenderingContextErrorMessageCallback; 97 class WebGLRenderingContextErrorMessageCallback;
98 98
99 class WebGLRenderingContextBase: public CanvasRenderingContext, public ActiveDOM Object, private Page::MultisamplingChangedObserver { 99 class WebGLRenderingContextBase: public CanvasRenderingContext, public ActiveDOM Object, private Page::MultisamplingChangedObserver {
100 public: 100 public:
101 virtual ~WebGLRenderingContextBase(); 101 virtual ~WebGLRenderingContextBase();
102 102
103 virtual bool is3d() const OVERRIDE { return true; }
104 virtual bool isAccelerated() const OVERRIDE { return true; }
105 virtual unsigned version() const = 0; 103 virtual unsigned version() const = 0;
106 virtual String contextName() const = 0; 104 virtual String contextName() const = 0;
107 virtual void registerContextExtensions() = 0; 105 virtual void registerContextExtensions() = 0;
108 106
109 static unsigned getWebGLVersion(const CanvasRenderingContext*); 107 static unsigned getWebGLVersion(const CanvasRenderingContext*);
110 108
111 int drawingBufferWidth() const; 109 int drawingBufferWidth() const;
112 int drawingBufferHeight() const; 110 int drawingBufferHeight() const;
113 111
114 void activeTexture(GLenum texture); 112 void activeTexture(GLenum texture);
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 319
322 // A synthetic lost context that should attempt to recover automatically 320 // A synthetic lost context that should attempt to recover automatically
323 AutoRecoverSyntheticLostContext 321 AutoRecoverSyntheticLostContext
324 }; 322 };
325 void forceLostContext(LostContextMode); 323 void forceLostContext(LostContextMode);
326 void forceRestoreContext(); 324 void forceRestoreContext();
327 void loseContextImpl(LostContextMode); 325 void loseContextImpl(LostContextMode);
328 326
329 blink::WebGraphicsContext3D* webContext() const { return m_drawingBuffer->co ntext(); } 327 blink::WebGraphicsContext3D* webContext() const { return m_drawingBuffer->co ntext(); }
330 WebGLContextGroup* contextGroup() const { return m_contextGroup.get(); } 328 WebGLContextGroup* contextGroup() const { return m_contextGroup.get(); }
331 virtual blink::WebLayer* platformLayer() const OVERRIDE;
332 Extensions3DUtil* extensionsUtil(); 329 Extensions3DUtil* extensionsUtil();
333 330
334 void reshape(int width, int height); 331 void reshape(int width, int height);
335 332
336 void markLayerComposited(); 333 void markLayerComposited();
337 virtual void paintRenderingResultsToCanvas() OVERRIDE;
338 PassRefPtrWillBeRawPtr<ImageData> paintRenderingResultsToImageData(); 334 PassRefPtrWillBeRawPtr<ImageData> paintRenderingResultsToImageData();
339 335
340 void removeSharedObject(WebGLSharedObject*); 336 void removeSharedObject(WebGLSharedObject*);
341 void removeContextObject(WebGLContextObject*); 337 void removeContextObject(WebGLContextObject*);
342 338
343 unsigned maxVertexAttribs() const { return m_maxVertexAttribs; } 339 unsigned maxVertexAttribs() const { return m_maxVertexAttribs; }
344 340
345 // ActiveDOMObject notifications 341 // ActiveDOMObject notifications
346 virtual bool hasPendingActivity() const OVERRIDE; 342 virtual bool hasPendingActivity() const OVERRIDE;
347 virtual void stop() OVERRIDE; 343 virtual void stop() OVERRIDE;
348 344
349 protected: 345 protected:
350 friend class WebGLDrawBuffers; 346 friend class WebGLDrawBuffers;
351 friend class WebGLFramebuffer; 347 friend class WebGLFramebuffer;
352 friend class WebGLObject; 348 friend class WebGLObject;
353 friend class OESVertexArrayObject; 349 friend class OESVertexArrayObject;
354 friend class WebGLDebugShaders; 350 friend class WebGLDebugShaders;
355 friend class WebGLCompressedTextureATC; 351 friend class WebGLCompressedTextureATC;
356 friend class WebGLCompressedTextureETC1; 352 friend class WebGLCompressedTextureETC1;
357 friend class WebGLCompressedTexturePVRTC; 353 friend class WebGLCompressedTexturePVRTC;
358 friend class WebGLCompressedTextureS3TC; 354 friend class WebGLCompressedTextureS3TC;
359 friend class WebGLRenderingContextErrorMessageCallback; 355 friend class WebGLRenderingContextErrorMessageCallback;
360 friend class WebGLVertexArrayObjectOES; 356 friend class WebGLVertexArrayObjectOES;
361 friend class ScopedTexture2DRestorer; 357 friend class ScopedTexture2DRestorer;
362 358
363 WebGLRenderingContextBase(HTMLCanvasElement*, PassOwnPtr<blink::WebGraphicsC ontext3D>, WebGLContextAttributes*); 359 WebGLRenderingContextBase(HTMLCanvasElement*, PassOwnPtr<blink::WebGraphicsC ontext3D>, WebGLContextAttributes*);
364 void initializeNewContext(); 360 void initializeNewContext();
365 void setupFlags(); 361 void setupFlags();
366 362
363 // CanvasRenderingContext implementation.
364 virtual bool is3d() const OVERRIDE { return true; }
Justin Novosad 2014/04/28 15:21:42 These are public in the base class. Making the pro
Ken Russell (switch to Gerrit) 2014/04/28 20:51:45 Actually, it was a common pattern in WebKit, anywa
dshwang 2014/04/29 16:07:04 I wanted to put them in private:, but there is not
365 virtual bool isAccelerated() const OVERRIDE { return true; }
366 virtual void setIsHidden(bool) OVERRIDE;
367 virtual void paintRenderingResultsToCanvas() OVERRIDE;
368 virtual blink::WebLayer* platformLayer() const OVERRIDE;
369
367 void addSharedObject(WebGLSharedObject*); 370 void addSharedObject(WebGLSharedObject*);
368 void addContextObject(WebGLContextObject*); 371 void addContextObject(WebGLContextObject*);
369 void detachAndRemoveAllObjects(); 372 void detachAndRemoveAllObjects();
370 373
371 void destroyContext(); 374 void destroyContext();
372 void markContextChanged(ContentChangeType); 375 void markContextChanged(ContentChangeType);
373 376
374 // Query if the GL implementation is NPOT strict. 377 // Query if the GL implementation is NPOT strict.
375 bool isGLES2NPOTStrict() { return m_isGLES2NPOTStrict; } 378 bool isGLES2NPOTStrict() { return m_isGLES2NPOTStrict; }
376 // Query if depth_stencil buffer is supported. 379 // Query if depth_stencil buffer is supported.
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 // If the vector is empty, return the maximum allowed active context number. 919 // If the vector is empty, return the maximum allowed active context number.
917 static size_t oldestContextIndex(); 920 static size_t oldestContextIndex();
918 static IntSize oldestContextSize(); 921 static IntSize oldestContextSize();
919 }; 922 };
920 923
921 DEFINE_TYPE_CASTS(WebGLRenderingContextBase, CanvasRenderingContext, context, co ntext->is3d(), context.is3d()); 924 DEFINE_TYPE_CASTS(WebGLRenderingContextBase, CanvasRenderingContext, context, co ntext->is3d(), context.is3d());
922 925
923 } // namespace WebCore 926 } // namespace WebCore
924 927
925 #endif // WebGLRenderingContextBase_h 928 #endif // WebGLRenderingContextBase_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698