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

Side by Side Diff: cc/output/gl_renderer.h

Issue 14273026: cc: Make async readback path use async glRreadPixels. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
OLDNEW
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 "cc/base/cc_export.h" 9 #include "cc/base/cc_export.h"
10 #include "cc/base/scoped_ptr_vector.h"
9 #include "cc/output/direct_renderer.h" 11 #include "cc/output/direct_renderer.h"
10 #include "cc/output/gl_renderer_draw_cache.h" 12 #include "cc/output/gl_renderer_draw_cache.h"
11 #include "cc/output/renderer.h" 13 #include "cc/output/renderer.h"
12 #include "cc/quads/checkerboard_draw_quad.h" 14 #include "cc/quads/checkerboard_draw_quad.h"
13 #include "cc/quads/debug_border_draw_quad.h" 15 #include "cc/quads/debug_border_draw_quad.h"
14 #include "cc/quads/io_surface_draw_quad.h" 16 #include "cc/quads/io_surface_draw_quad.h"
15 #include "cc/quads/render_pass_draw_quad.h" 17 #include "cc/quads/render_pass_draw_quad.h"
16 #include "cc/quads/solid_color_draw_quad.h" 18 #include "cc/quads/solid_color_draw_quad.h"
17 #include "cc/quads/tile_draw_quad.h" 19 #include "cc/quads/tile_draw_quad.h"
18 #include "cc/quads/yuv_video_draw_quad.h" 20 #include "cc/quads/yuv_video_draw_quad.h"
19 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h" 21 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3 D.h"
20 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsMemoryAl location.h" 22 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsMemoryAl location.h"
21 #include "ui/gfx/quad_f.h" 23 #include "ui/gfx/quad_f.h"
22 24
25 class SkBitmap;
26
23 namespace cc { 27 namespace cc {
24 28
25 class GLRendererShaderTest; 29 class GLRendererShaderTest;
26 class OutputSurface; 30 class OutputSurface;
27 class PictureDrawQuad; 31 class PictureDrawQuad;
28 class ScopedResource; 32 class ScopedResource;
29 class StreamVideoDrawQuad; 33 class StreamVideoDrawQuad;
30 class TextureDrawQuad; 34 class TextureDrawQuad;
31 class GeometryBinding; 35 class GeometryBinding;
32 class ScopedEnsureFramebufferAllocation; 36 class ScopedEnsureFramebufferAllocation;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 int highp_threshold_min); 84 int highp_threshold_min);
81 85
82 bool IsBackbufferDiscarded() const { return is_backbuffer_discarded_; } 86 bool IsBackbufferDiscarded() const { return is_backbuffer_discarded_; }
83 bool Initialize(); 87 bool Initialize();
84 88
85 const gfx::QuadF& SharedGeometryQuad() const { return shared_geometry_quad_; } 89 const gfx::QuadF& SharedGeometryQuad() const { return shared_geometry_quad_; }
86 const GeometryBinding* SharedGeometry() const { 90 const GeometryBinding* SharedGeometry() const {
87 return shared_geometry_.get(); 91 return shared_geometry_.get();
88 } 92 }
89 93
94 void GetFramebufferPixelsAsync(gfx::Rect rect,
95 CopyRenderPassCallback callback);
90 bool GetFramebufferTexture(ScopedResource* resource, gfx::Rect device_rect); 96 bool GetFramebufferTexture(ScopedResource* resource, gfx::Rect device_rect);
91 void ReleaseRenderPassTextures(); 97 void ReleaseRenderPassTextures();
92 98
93 virtual void BindFramebufferToOutputSurface(DrawingFrame* frame) OVERRIDE; 99 virtual void BindFramebufferToOutputSurface(DrawingFrame* frame) OVERRIDE;
94 virtual bool BindFramebufferToTexture(DrawingFrame* frame, 100 virtual bool BindFramebufferToTexture(DrawingFrame* frame,
95 const ScopedResource* resource, 101 const ScopedResource* resource,
96 gfx::Rect framebuffer_rect) OVERRIDE; 102 gfx::Rect framebuffer_rect) OVERRIDE;
97 virtual void SetDrawViewportSize(gfx::Size viewport_size) OVERRIDE; 103 virtual void SetDrawViewportSize(gfx::Size viewport_size) OVERRIDE;
98 virtual void SetScissorTestRect(gfx::Rect scissor_rect) OVERRIDE; 104 virtual void SetScissorTestRect(gfx::Rect scissor_rect) OVERRIDE;
99 virtual void ClearFramebuffer(DrawingFrame* frame) OVERRIDE; 105 virtual void ClearFramebuffer(DrawingFrame* frame) OVERRIDE;
100 virtual void DoDrawQuad(DrawingFrame* frame, const class DrawQuad*) OVERRIDE; 106 virtual void DoDrawQuad(DrawingFrame* frame, const class DrawQuad*) OVERRIDE;
101 virtual void BeginDrawingFrame(DrawingFrame* frame) OVERRIDE; 107 virtual void BeginDrawingFrame(DrawingFrame* frame) OVERRIDE;
102 virtual void FinishDrawingFrame(DrawingFrame* frame) OVERRIDE; 108 virtual void FinishDrawingFrame(DrawingFrame* frame) OVERRIDE;
103 virtual bool FlippedFramebuffer() const OVERRIDE; 109 virtual bool FlippedFramebuffer() const OVERRIDE;
104 virtual void EnsureScissorTestEnabled() OVERRIDE; 110 virtual void EnsureScissorTestEnabled() OVERRIDE;
105 virtual void EnsureScissorTestDisabled() OVERRIDE; 111 virtual void EnsureScissorTestDisabled() OVERRIDE;
106 virtual void CopyCurrentRenderPassToBitmap(DrawingFrame* frame, 112 virtual void CopyCurrentRenderPassToBitmap(
107 SkBitmap* bitmap) OVERRIDE; 113 DrawingFrame* frame,
114 const CopyRenderPassCallback& callback) OVERRIDE;
108 virtual void FinishDrawingQuadList() OVERRIDE; 115 virtual void FinishDrawingQuadList() OVERRIDE;
109 116
110 private: 117 private:
111 friend class GLRendererShaderPixelTest; 118 friend class GLRendererShaderPixelTest;
112 friend class GLRendererShaderTest; 119 friend class GLRendererShaderTest;
113 120
114 static void ToGLMatrix(float* gl_matrix, const gfx::Transform& transform); 121 static void ToGLMatrix(float* gl_matrix, const gfx::Transform& transform);
115 static ManagedMemoryPolicy::PriorityCutoff PriorityCutoff( 122 static ManagedMemoryPolicy::PriorityCutoff PriorityCutoff(
116 WebKit::WebGraphicsMemoryAllocation::PriorityCutoff priority_cutoff); 123 WebKit::WebGraphicsMemoryAllocation::PriorityCutoff priority_cutoff);
117 124
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 179
173 bool UseScopedTexture(DrawingFrame* frame, 180 bool UseScopedTexture(DrawingFrame* frame,
174 const ScopedResource* resource, 181 const ScopedResource* resource,
175 gfx::Rect viewport_rect); 182 gfx::Rect viewport_rect);
176 183
177 bool MakeContextCurrent(); 184 bool MakeContextCurrent();
178 185
179 bool InitializeSharedObjects(); 186 bool InitializeSharedObjects();
180 void CleanupSharedObjects(); 187 void CleanupSharedObjects();
181 188
189 typedef base::Callback<void(bool success)>
190 AsyncGetFramebufferPixelsCleanupCallback;
191 void DoGetFramebufferPixels(
192 uint8* pixels,
193 gfx::Rect rect,
194 const AsyncGetFramebufferPixelsCleanupCallback& cleanup_callback);
195 void FinishedReadback(
196 const AsyncGetFramebufferPixelsCleanupCallback& cleanup_callback,
197 unsigned source_buffer,
198 uint8_t* dest_pixels,
199 gfx::Size size);
200 void PassOnSkBitmap(
201 scoped_ptr<SkBitmap> bitmap,
202 scoped_ptr<SkAutoLockPixels> lock,
203 const CopyRenderPassCallback& callback,
204 bool success);
205
182 // WebKit:: 206 // WebKit::
183 // WebGraphicsContext3D::WebGraphicsMemoryAllocationChangedCallbackCHROMIUM 207 // WebGraphicsContext3D::WebGraphicsMemoryAllocationChangedCallbackCHROMIUM
184 // implementation. 208 // implementation.
185 virtual void onMemoryAllocationChanged( 209 virtual void onMemoryAllocationChanged(
186 WebKit::WebGraphicsMemoryAllocation allocation) OVERRIDE; 210 WebKit::WebGraphicsMemoryAllocation allocation) OVERRIDE;
187 void DiscardBackbuffer(); 211 void DiscardBackbuffer();
188 void EnsureBackbuffer(); 212 void EnsureBackbuffer();
189 void EnforceMemoryPolicy(); 213 void EnforceMemoryPolicy();
190 214
191 RendererCapabilities capabilities_; 215 RendererCapabilities capabilities_;
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 bool is_backbuffer_discarded_; 395 bool is_backbuffer_discarded_;
372 bool discard_backbuffer_when_not_visible_; 396 bool discard_backbuffer_when_not_visible_;
373 bool is_using_bind_uniform_; 397 bool is_using_bind_uniform_;
374 bool visible_; 398 bool visible_;
375 bool is_scissor_enabled_; 399 bool is_scissor_enabled_;
376 bool blend_shadow_; 400 bool blend_shadow_;
377 unsigned program_shadow_; 401 unsigned program_shadow_;
378 TexturedQuadDrawCache draw_cache_; 402 TexturedQuadDrawCache draw_cache_;
379 int highp_threshold_min_; 403 int highp_threshold_min_;
380 404
405 struct PendingAsyncReadPixels;
406 ScopedPtrVector<PendingAsyncReadPixels> pending_async_read_pixels_;
407
381 scoped_ptr<ResourceProvider::ScopedWriteLockGL> current_framebuffer_lock_; 408 scoped_ptr<ResourceProvider::ScopedWriteLockGL> current_framebuffer_lock_;
382 409
383 scoped_refptr<ResourceProvider::Fence> last_swap_fence_; 410 scoped_refptr<ResourceProvider::Fence> last_swap_fence_;
384 411
385 SkBitmap on_demand_tile_raster_bitmap_; 412 SkBitmap on_demand_tile_raster_bitmap_;
386 ResourceProvider::ResourceId on_demand_tile_raster_resource_id_; 413 ResourceProvider::ResourceId on_demand_tile_raster_resource_id_;
387 414
388 DISALLOW_COPY_AND_ASSIGN(GLRenderer); 415 DISALLOW_COPY_AND_ASSIGN(GLRenderer);
389 }; 416 };
390 417
391 // Setting DEBUG_GL_CALLS to 1 will call glGetError() after almost every GL 418 // Setting DEBUG_GL_CALLS to 1 will call glGetError() after almost every GL
392 // call made by the compositor. Useful for debugging rendering issues but 419 // call made by the compositor. Useful for debugging rendering issues but
393 // will significantly degrade performance. 420 // will significantly degrade performance.
394 #define DEBUG_GL_CALLS 0 421 #define DEBUG_GL_CALLS 0
395 422
396 #if DEBUG_GL_CALLS && !defined(NDEBUG) 423 #if DEBUG_GL_CALLS && !defined(NDEBUG)
397 #define GLC(context, x) \ 424 #define GLC(context, x) \
398 (x, GLRenderer::DebugGLCall(&* context, #x, __FILE__, __LINE__)) 425 (x, GLRenderer::DebugGLCall(&* context, #x, __FILE__, __LINE__))
399 #else 426 #else
400 #define GLC(context, x) (x) 427 #define GLC(context, x) (x)
401 #endif 428 #endif
402 429
403 } // namespace cc 430 } // namespace cc
404 431
405 #endif // CC_OUTPUT_GL_RENDERER_H_ 432 #endif // CC_OUTPUT_GL_RENDERER_H_
OLDNEW
« no previous file with comments | « cc/output/direct_renderer.cc ('k') | cc/output/gl_renderer.cc » ('j') | cc/output/gl_renderer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698