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

Side by Side Diff: content/common/gpu/client/grcontext_for_webgraphicscontext3d.h

Issue 1414683003: Fix gpu command buffer use after free by GrContext (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: blind android fix Created 5 years, 1 month 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 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_COMMON_GPU_CLIENT_GRCONTEXT_FOR_WEBGRAPHICSCONTEXT3D_H_ 5 #ifndef CONTENT_COMMON_GPU_CLIENT_GRCONTEXT_FOR_WEBGRAPHICSCONTEXT3D_H_
6 #define CONTENT_COMMON_GPU_CLIENT_GRCONTEXT_FOR_WEBGRAPHICSCONTEXT3D_H_ 6 #define CONTENT_COMMON_GPU_CLIENT_GRCONTEXT_FOR_WEBGRAPHICSCONTEXT3D_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h"
9 #include "skia/ext/refptr.h" 10 #include "skia/ext/refptr.h"
11 #include "third_party/skia/include/gpu/gl/GrGLInterface.h"
10 12
11 class GrContext; 13 class GrContext;
12 14
13 namespace gpu_blink { 15 namespace gpu_blink {
14 class WebGraphicsContext3DImpl; 16 class WebGraphicsContext3DImpl;
15 } 17 }
16 18
17 namespace content { 19 namespace content {
18 20
21 // Wrap WebGraphicsContext3DImpl into a GrGLInterface object, which allows
22 // the WebGraphicsContext3DImpl to be jointly refcounted (indirectly)
23 // by the GrContext and the context provider. This makes it legal for the
24 // GrContext to be invoked when it outlives the context provider that created
25 // it. By doing this we no longer have to worry about use after free errors
26 // caused a lack of consideration for object destruction order.
27 class GrGLInterfaceForWebGraphicsContext3D final : public GrGLInterface {
28 public:
29 GrGLInterfaceForWebGraphicsContext3D(
30 scoped_ptr<gpu_blink::WebGraphicsContext3DImpl> context3d);
31 ~GrGLInterfaceForWebGraphicsContext3D() final;
32
33 gpu_blink::WebGraphicsContext3DImpl* WebContext3D() const {
34 return context3d_.get();
35 }
36 private:
37 scoped_ptr<gpu_blink::WebGraphicsContext3DImpl> context3d_;
38 };
39
19 // This class binds an offscreen GrContext to an offscreen context3d. The 40 // This class binds an offscreen GrContext to an offscreen context3d. The
20 // context3d is used by the GrContext so must be valid as long as this class 41 // context3d is used by the GrContext so must be valid as long as this class
21 // is alive. 42 // is alive.
22 class GrContextForWebGraphicsContext3D { 43 class GrContextForWebGraphicsContext3D {
23 public: 44 public:
24 explicit GrContextForWebGraphicsContext3D( 45 explicit GrContextForWebGraphicsContext3D(
25 gpu_blink::WebGraphicsContext3DImpl* context3d); 46 skia::RefPtr<GrGLInterfaceForWebGraphicsContext3D> context3d);
26 virtual ~GrContextForWebGraphicsContext3D(); 47 virtual ~GrContextForWebGraphicsContext3D();
27 48
28 GrContext* get() { return gr_context_.get(); } 49 GrContext* get() { return gr_context_.get(); }
29 50
30 void OnLostContext(); 51 void OnLostContext();
31 void FreeGpuResources(); 52 void FreeGpuResources();
32 53
33 private: 54 private:
34 skia::RefPtr<class GrContext> gr_context_; 55 skia::RefPtr<class GrContext> gr_context_;
35 56
36 DISALLOW_COPY_AND_ASSIGN(GrContextForWebGraphicsContext3D); 57 DISALLOW_COPY_AND_ASSIGN(GrContextForWebGraphicsContext3D);
37 }; 58 };
38 59
39 } // namespace content 60 } // namespace content
40 61
41 #endif // CONTENT_COMMON_GPU_CLIENT_GRCONTEXT_FOR_WEBGRAPHICSCONTEXT3D_H_ 62 #endif // CONTENT_COMMON_GPU_CLIENT_GRCONTEXT_FOR_WEBGRAPHICSCONTEXT3D_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698