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

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: There, I fixed it Created 7 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 | 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 GetFramebufferPixels(gfx::Rect rect, CopyRenderPassCallback callback);
piman 2013/04/27 00:42:25 nit: can we avoid overloading? Especially if one i
danakj 2013/04/29 14:59:05 Oh gosh, yes you're right. Renamed back to GetFram
90 bool GetFramebufferTexture(ScopedResource* resource, gfx::Rect device_rect); 95 bool GetFramebufferTexture(ScopedResource* resource, gfx::Rect device_rect);
91 void ReleaseRenderPassTextures(); 96 void ReleaseRenderPassTextures();
92 97
93 virtual void BindFramebufferToOutputSurface(DrawingFrame* frame) OVERRIDE; 98 virtual void BindFramebufferToOutputSurface(DrawingFrame* frame) OVERRIDE;
94 virtual bool BindFramebufferToTexture(DrawingFrame* frame, 99 virtual bool BindFramebufferToTexture(DrawingFrame* frame,
95 const ScopedResource* resource, 100 const ScopedResource* resource,
96 gfx::Rect framebuffer_rect) OVERRIDE; 101 gfx::Rect framebuffer_rect) OVERRIDE;
97 virtual void SetDrawViewportSize(gfx::Size viewport_size) OVERRIDE; 102 virtual void SetDrawViewportSize(gfx::Size viewport_size) OVERRIDE;
98 virtual void SetScissorTestRect(gfx::Rect scissor_rect) OVERRIDE; 103 virtual void SetScissorTestRect(gfx::Rect scissor_rect) OVERRIDE;
99 virtual void ClearFramebuffer(DrawingFrame* frame) OVERRIDE; 104 virtual void ClearFramebuffer(DrawingFrame* frame) OVERRIDE;
100 virtual void DoDrawQuad(DrawingFrame* frame, const class DrawQuad*) OVERRIDE; 105 virtual void DoDrawQuad(DrawingFrame* frame, const class DrawQuad*) OVERRIDE;
101 virtual void BeginDrawingFrame(DrawingFrame* frame) OVERRIDE; 106 virtual void BeginDrawingFrame(DrawingFrame* frame) OVERRIDE;
102 virtual void FinishDrawingFrame(DrawingFrame* frame) OVERRIDE; 107 virtual void FinishDrawingFrame(DrawingFrame* frame) OVERRIDE;
103 virtual bool FlippedFramebuffer() const OVERRIDE; 108 virtual bool FlippedFramebuffer() const OVERRIDE;
104 virtual void EnsureScissorTestEnabled() OVERRIDE; 109 virtual void EnsureScissorTestEnabled() OVERRIDE;
105 virtual void EnsureScissorTestDisabled() OVERRIDE; 110 virtual void EnsureScissorTestDisabled() OVERRIDE;
106 virtual void CopyCurrentRenderPassToBitmap(DrawingFrame* frame, 111 virtual void CopyCurrentRenderPassToBitmap(
107 SkBitmap* bitmap) OVERRIDE; 112 DrawingFrame* frame,
113 const CopyRenderPassCallback& callback) OVERRIDE;
108 virtual void FinishDrawingQuadList() OVERRIDE; 114 virtual void FinishDrawingQuadList() OVERRIDE;
109 115
110 private: 116 private:
111 friend class GLRendererShaderPixelTest; 117 friend class GLRendererShaderPixelTest;
112 friend class GLRendererShaderTest; 118 friend class GLRendererShaderTest;
113 119
114 static void ToGLMatrix(float* gl_matrix, const gfx::Transform& transform); 120 static void ToGLMatrix(float* gl_matrix, const gfx::Transform& transform);
115 static ManagedMemoryPolicy::PriorityCutoff PriorityCutoff( 121 static ManagedMemoryPolicy::PriorityCutoff PriorityCutoff(
116 WebKit::WebGraphicsMemoryAllocation::PriorityCutoff priority_cutoff); 122 WebKit::WebGraphicsMemoryAllocation::PriorityCutoff priority_cutoff);
117 123
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 178
173 bool UseScopedTexture(DrawingFrame* frame, 179 bool UseScopedTexture(DrawingFrame* frame,
174 const ScopedResource* resource, 180 const ScopedResource* resource,
175 gfx::Rect viewport_rect); 181 gfx::Rect viewport_rect);
176 182
177 bool MakeContextCurrent(); 183 bool MakeContextCurrent();
178 184
179 bool InitializeSharedObjects(); 185 bool InitializeSharedObjects();
180 void CleanupSharedObjects(); 186 void CleanupSharedObjects();
181 187
188 typedef base::Callback<void(bool success)>
189 AsyncGetFramebufferPixelsCleanupCallback;
190 void DoGetFramebufferPixels(
191 uint8* pixels,
192 gfx::Rect rect,
193 const AsyncGetFramebufferPixelsCleanupCallback& cleanup_callback);
194 void FinishedReadback(
195 const AsyncGetFramebufferPixelsCleanupCallback& cleanup_callback,
196 unsigned source_buffer,
197 scoped_ptr<uint8[]> sync_pixels,
198 uint8_t* dest_pixels,
199 gfx::Size size,
200 unsigned sync_point);
201 void PassOnSkBitmap(
202 scoped_ptr<SkBitmap> bitmap,
203 scoped_ptr<SkAutoLockPixels> lock,
204 const CopyRenderPassCallback& callback,
205 bool success);
206
182 // WebKit:: 207 // WebKit::
183 // WebGraphicsContext3D::WebGraphicsMemoryAllocationChangedCallbackCHROMIUM 208 // WebGraphicsContext3D::WebGraphicsMemoryAllocationChangedCallbackCHROMIUM
184 // implementation. 209 // implementation.
185 virtual void onMemoryAllocationChanged( 210 virtual void onMemoryAllocationChanged(
186 WebKit::WebGraphicsMemoryAllocation allocation) OVERRIDE; 211 WebKit::WebGraphicsMemoryAllocation allocation) OVERRIDE;
187 void DiscardBackbuffer(); 212 void DiscardBackbuffer();
188 void EnsureBackbuffer(); 213 void EnsureBackbuffer();
189 void EnforceMemoryPolicy(); 214 void EnforceMemoryPolicy();
190 215
191 RendererCapabilities capabilities_; 216 RendererCapabilities capabilities_;
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 bool is_backbuffer_discarded_; 396 bool is_backbuffer_discarded_;
372 bool discard_backbuffer_when_not_visible_; 397 bool discard_backbuffer_when_not_visible_;
373 bool is_using_bind_uniform_; 398 bool is_using_bind_uniform_;
374 bool visible_; 399 bool visible_;
375 bool is_scissor_enabled_; 400 bool is_scissor_enabled_;
376 bool blend_shadow_; 401 bool blend_shadow_;
377 unsigned program_shadow_; 402 unsigned program_shadow_;
378 TexturedQuadDrawCache draw_cache_; 403 TexturedQuadDrawCache draw_cache_;
379 int highp_threshold_min_; 404 int highp_threshold_min_;
380 405
406 struct PendingAsyncReadPixels;
407 ScopedPtrVector<PendingAsyncReadPixels> pending_async_read_pixels_;
408
381 scoped_ptr<ResourceProvider::ScopedWriteLockGL> current_framebuffer_lock_; 409 scoped_ptr<ResourceProvider::ScopedWriteLockGL> current_framebuffer_lock_;
382 410
383 scoped_refptr<ResourceProvider::Fence> last_swap_fence_; 411 scoped_refptr<ResourceProvider::Fence> last_swap_fence_;
384 412
385 SkBitmap on_demand_tile_raster_bitmap_; 413 SkBitmap on_demand_tile_raster_bitmap_;
386 ResourceProvider::ResourceId on_demand_tile_raster_resource_id_; 414 ResourceProvider::ResourceId on_demand_tile_raster_resource_id_;
387 415
388 DISALLOW_COPY_AND_ASSIGN(GLRenderer); 416 DISALLOW_COPY_AND_ASSIGN(GLRenderer);
389 }; 417 };
390 418
391 // Setting DEBUG_GL_CALLS to 1 will call glGetError() after almost every GL 419 // 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 420 // call made by the compositor. Useful for debugging rendering issues but
393 // will significantly degrade performance. 421 // will significantly degrade performance.
394 #define DEBUG_GL_CALLS 0 422 #define DEBUG_GL_CALLS 0
395 423
396 #if DEBUG_GL_CALLS && !defined(NDEBUG) 424 #if DEBUG_GL_CALLS && !defined(NDEBUG)
397 #define GLC(context, x) \ 425 #define GLC(context, x) \
398 (x, GLRenderer::DebugGLCall(&* context, #x, __FILE__, __LINE__)) 426 (x, GLRenderer::DebugGLCall(&* context, #x, __FILE__, __LINE__))
399 #else 427 #else
400 #define GLC(context, x) (x) 428 #define GLC(context, x) (x)
401 #endif 429 #endif
402 430
403 } // namespace cc 431 } // namespace cc
404 432
405 #endif // CC_OUTPUT_GL_RENDERER_H_ 433 #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