OLD | NEW |
1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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 CC_OUTPUT_GL_RENDERER_H_ | 5 #ifndef CC_OUTPUT_GL_RENDERER_H_ |
6 #define CC_OUTPUT_GL_RENDERER_H_ | 6 #define CC_OUTPUT_GL_RENDERER_H_ |
7 | 7 |
8 #include "base/cancelable_callback.h" | 8 #include "base/cancelable_callback.h" |
9 #include "cc/base/cc_export.h" | 9 #include "cc/base/cc_export.h" |
10 #include "cc/base/scoped_ptr_deque.h" | 10 #include "cc/base/scoped_ptr_deque.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 class ScopedUseGrContext; | 48 class ScopedUseGrContext; |
49 | 49 |
50 static scoped_ptr<GLRenderer> Create( | 50 static scoped_ptr<GLRenderer> Create( |
51 RendererClient* client, | 51 RendererClient* client, |
52 const LayerTreeSettings* settings, | 52 const LayerTreeSettings* settings, |
53 OutputSurface* output_surface, | 53 OutputSurface* output_surface, |
54 ResourceProvider* resource_provider, | 54 ResourceProvider* resource_provider, |
55 TextureMailboxDeleter* texture_mailbox_deleter, | 55 TextureMailboxDeleter* texture_mailbox_deleter, |
56 int highp_threshold_min); | 56 int highp_threshold_min); |
57 | 57 |
58 virtual ~GLRenderer(); | 58 ~GLRenderer() override; |
59 | 59 |
60 virtual const RendererCapabilitiesImpl& Capabilities() const override; | 60 const RendererCapabilitiesImpl& Capabilities() const override; |
61 | 61 |
62 // Waits for rendering to finish. | 62 // Waits for rendering to finish. |
63 virtual void Finish() override; | 63 void Finish() override; |
64 | 64 |
65 virtual void DoNoOp() override; | 65 void DoNoOp() override; |
66 virtual void SwapBuffers(const CompositorFrameMetadata& metadata) override; | 66 void SwapBuffers(const CompositorFrameMetadata& metadata) override; |
67 | 67 |
68 virtual bool IsContextLost(); | 68 virtual bool IsContextLost(); |
69 | 69 |
70 static void DebugGLCall(gpu::gles2::GLES2Interface* gl, | 70 static void DebugGLCall(gpu::gles2::GLES2Interface* gl, |
71 const char* command, | 71 const char* command, |
72 const char* file, | 72 const char* file, |
73 int line); | 73 int line); |
74 | 74 |
75 protected: | 75 protected: |
76 GLRenderer(RendererClient* client, | 76 GLRenderer(RendererClient* client, |
77 const LayerTreeSettings* settings, | 77 const LayerTreeSettings* settings, |
78 OutputSurface* output_surface, | 78 OutputSurface* output_surface, |
79 ResourceProvider* resource_provider, | 79 ResourceProvider* resource_provider, |
80 TextureMailboxDeleter* texture_mailbox_deleter, | 80 TextureMailboxDeleter* texture_mailbox_deleter, |
81 int highp_threshold_min); | 81 int highp_threshold_min); |
82 | 82 |
83 virtual void DidChangeVisibility() override; | 83 void DidChangeVisibility() override; |
84 | 84 |
85 bool IsBackbufferDiscarded() const { return is_backbuffer_discarded_; } | 85 bool IsBackbufferDiscarded() const { return is_backbuffer_discarded_; } |
86 | 86 |
87 const gfx::QuadF& SharedGeometryQuad() const { return shared_geometry_quad_; } | 87 const gfx::QuadF& SharedGeometryQuad() const { return shared_geometry_quad_; } |
88 const GeometryBinding* SharedGeometry() const { | 88 const GeometryBinding* SharedGeometry() const { |
89 return shared_geometry_.get(); | 89 return shared_geometry_.get(); |
90 } | 90 } |
91 | 91 |
92 void GetFramebufferPixelsAsync(const gfx::Rect& rect, | 92 void GetFramebufferPixelsAsync(const gfx::Rect& rect, |
93 scoped_ptr<CopyOutputRequest> request); | 93 scoped_ptr<CopyOutputRequest> request); |
94 void GetFramebufferTexture(unsigned texture_id, | 94 void GetFramebufferTexture(unsigned texture_id, |
95 ResourceFormat texture_format, | 95 ResourceFormat texture_format, |
96 const gfx::Rect& device_rect); | 96 const gfx::Rect& device_rect); |
97 void ReleaseRenderPassTextures(); | 97 void ReleaseRenderPassTextures(); |
98 | 98 |
99 void SetStencilEnabled(bool enabled); | 99 void SetStencilEnabled(bool enabled); |
100 bool stencil_enabled() const { return stencil_shadow_; } | 100 bool stencil_enabled() const { return stencil_shadow_; } |
101 void SetBlendEnabled(bool enabled); | 101 void SetBlendEnabled(bool enabled); |
102 bool blend_enabled() const { return blend_shadow_; } | 102 bool blend_enabled() const { return blend_shadow_; } |
103 | 103 |
104 virtual void BindFramebufferToOutputSurface(DrawingFrame* frame) override; | 104 void BindFramebufferToOutputSurface(DrawingFrame* frame) override; |
105 virtual bool BindFramebufferToTexture(DrawingFrame* frame, | 105 bool BindFramebufferToTexture(DrawingFrame* frame, |
106 const ScopedResource* resource, | 106 const ScopedResource* resource, |
107 const gfx::Rect& target_rect) override; | 107 const gfx::Rect& target_rect) override; |
108 virtual void SetDrawViewport(const gfx::Rect& window_space_viewport) override; | 108 void SetDrawViewport(const gfx::Rect& window_space_viewport) override; |
109 virtual void SetScissorTestRect(const gfx::Rect& scissor_rect) override; | 109 void SetScissorTestRect(const gfx::Rect& scissor_rect) override; |
110 virtual void DiscardPixels(bool has_external_stencil_test, | 110 void DiscardPixels(bool has_external_stencil_test, |
111 bool draw_rect_covers_full_surface) override; | 111 bool draw_rect_covers_full_surface) override; |
112 virtual void ClearFramebuffer(DrawingFrame* frame, | 112 void ClearFramebuffer(DrawingFrame* frame, |
113 bool has_external_stencil_test) override; | 113 bool has_external_stencil_test) override; |
114 virtual void DoDrawQuad(DrawingFrame* frame, const class DrawQuad*) override; | 114 void DoDrawQuad(DrawingFrame* frame, const class DrawQuad*) override; |
115 virtual void BeginDrawingFrame(DrawingFrame* frame) override; | 115 void BeginDrawingFrame(DrawingFrame* frame) override; |
116 virtual void FinishDrawingFrame(DrawingFrame* frame) override; | 116 void FinishDrawingFrame(DrawingFrame* frame) override; |
117 virtual bool FlippedFramebuffer() const override; | 117 bool FlippedFramebuffer() const override; |
118 virtual void EnsureScissorTestEnabled() override; | 118 void EnsureScissorTestEnabled() override; |
119 virtual void EnsureScissorTestDisabled() override; | 119 void EnsureScissorTestDisabled() override; |
120 virtual void CopyCurrentRenderPassToBitmap( | 120 void CopyCurrentRenderPassToBitmap( |
121 DrawingFrame* frame, | 121 DrawingFrame* frame, |
122 scoped_ptr<CopyOutputRequest> request) override; | 122 scoped_ptr<CopyOutputRequest> request) override; |
123 virtual void FinishDrawingQuadList() override; | 123 void FinishDrawingQuadList() override; |
124 | 124 |
125 // Check if quad needs antialiasing and if so, inflate the quad and | 125 // Check if quad needs antialiasing and if so, inflate the quad and |
126 // fill edge array for fragment shader. local_quad is set to | 126 // fill edge array for fragment shader. local_quad is set to |
127 // inflated quad if antialiasing is required, otherwise it is left | 127 // inflated quad if antialiasing is required, otherwise it is left |
128 // unchanged. edge array is filled with inflated quad's edge data | 128 // unchanged. edge array is filled with inflated quad's edge data |
129 // if antialiasing is required, otherwise it is left unchanged. | 129 // if antialiasing is required, otherwise it is left unchanged. |
130 // Returns true if quad requires antialiasing and false otherwise. | 130 // Returns true if quad requires antialiasing and false otherwise. |
131 static bool SetupQuadForAntialiasing(const gfx::Transform& device_transform, | 131 static bool SetupQuadForAntialiasing(const gfx::Transform& device_transform, |
132 const DrawQuad* quad, | 132 const DrawQuad* quad, |
133 gfx::QuadF* local_quad, | 133 gfx::QuadF* local_quad, |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 bool success)> | 216 bool success)> |
217 AsyncGetFramebufferPixelsCleanupCallback; | 217 AsyncGetFramebufferPixelsCleanupCallback; |
218 void FinishedReadback(unsigned source_buffer, | 218 void FinishedReadback(unsigned source_buffer, |
219 unsigned query, | 219 unsigned query, |
220 const gfx::Size& size); | 220 const gfx::Size& size); |
221 | 221 |
222 void ReinitializeGLState(); | 222 void ReinitializeGLState(); |
223 void RestoreGLState(); | 223 void RestoreGLState(); |
224 void RestoreFramebuffer(DrawingFrame* frame); | 224 void RestoreFramebuffer(DrawingFrame* frame); |
225 | 225 |
226 virtual void DiscardBackbuffer() override; | 226 void DiscardBackbuffer() override; |
227 virtual void EnsureBackbuffer() override; | 227 void EnsureBackbuffer() override; |
228 void EnforceMemoryPolicy(); | 228 void EnforceMemoryPolicy(); |
229 | 229 |
230 void ScheduleOverlays(DrawingFrame* frame); | 230 void ScheduleOverlays(DrawingFrame* frame); |
231 | 231 |
232 typedef ScopedPtrVector<ResourceProvider::ScopedReadLockGL> | 232 typedef ScopedPtrVector<ResourceProvider::ScopedReadLockGL> |
233 OverlayResourceLockList; | 233 OverlayResourceLockList; |
234 OverlayResourceLockList pending_overlay_resources_; | 234 OverlayResourceLockList pending_overlay_resources_; |
235 OverlayResourceLockList in_use_overlay_resources_; | 235 OverlayResourceLockList in_use_overlay_resources_; |
236 | 236 |
237 RendererCapabilitiesImpl capabilities_; | 237 RendererCapabilitiesImpl capabilities_; |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 #if DEBUG_GL_CALLS && !defined(NDEBUG) | 455 #if DEBUG_GL_CALLS && !defined(NDEBUG) |
456 #define GLC(context, x) \ | 456 #define GLC(context, x) \ |
457 (x, GLRenderer::DebugGLCall(&* context, #x, __FILE__, __LINE__)) | 457 (x, GLRenderer::DebugGLCall(&* context, #x, __FILE__, __LINE__)) |
458 #else | 458 #else |
459 #define GLC(context, x) (x) | 459 #define GLC(context, x) (x) |
460 #endif | 460 #endif |
461 | 461 |
462 } // namespace cc | 462 } // namespace cc |
463 | 463 |
464 #endif // CC_OUTPUT_GL_RENDERER_H_ | 464 #endif // CC_OUTPUT_GL_RENDERER_H_ |
OLD | NEW |