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 24 matching lines...) Expand all Loading... | |
35 class GLRendererShaderTest; | 35 class GLRendererShaderTest; |
36 class OutputSurface; | 36 class OutputSurface; |
37 class PictureDrawQuad; | 37 class PictureDrawQuad; |
38 class ScopedResource; | 38 class ScopedResource; |
39 class StreamVideoDrawQuad; | 39 class StreamVideoDrawQuad; |
40 class TextureDrawQuad; | 40 class TextureDrawQuad; |
41 class TextureMailboxDeleter; | 41 class TextureMailboxDeleter; |
42 class GeometryBinding; | 42 class GeometryBinding; |
43 class ScopedEnsureFramebufferAllocation; | 43 class ScopedEnsureFramebufferAllocation; |
44 | 44 |
45 static const SkXfermode::Mode kDefaultBlendMode = SkXfermode::kSrcOver_Mode; | |
46 static const SkXfermode::Mode kFirstBlendMode = SkXfermode::kScreen_Mode; | |
47 static const SkXfermode::Mode kLastBlendMode = SkXfermode::kLuminosity_Mode; | |
48 static const int kNumBlendModes = kLastBlendMode - kFirstBlendMode + 2; | |
enne (OOO)
2014/10/16 01:41:25
Would it make sense to add these to Skia?
rosca
2014/10/16 16:14:56
Actually, we don't need coeff blend modes for shad
| |
49 static inline int index_for_blend_mode(SkXfermode::Mode blend_mode) { | |
50 return (blend_mode < kFirstBlendMode || blend_mode > kLastBlendMode) | |
51 ? 0 | |
52 : blend_mode - kFirstBlendMode + 1; | |
53 } | |
54 | |
55 static_assert( | |
56 kDefaultBlendMode < kFirstBlendMode && kFirstBlendMode < kLastBlendMode, | |
57 "The order should be: kSrcOver_Mode, kFirstBlendMode, kLastBlendMode"); | |
58 static_assert(kNumBlendModes == 16, "There are 16 blend modes."); | |
59 | |
45 // Class that handles drawing of composited render layers using GL. | 60 // Class that handles drawing of composited render layers using GL. |
46 class CC_EXPORT GLRenderer : public DirectRenderer { | 61 class CC_EXPORT GLRenderer : public DirectRenderer { |
47 public: | 62 public: |
48 class ScopedUseGrContext; | 63 class ScopedUseGrContext; |
49 | 64 |
50 static scoped_ptr<GLRenderer> Create( | 65 static scoped_ptr<GLRenderer> Create( |
51 RendererClient* client, | 66 RendererClient* client, |
52 const LayerTreeSettings* settings, | 67 const LayerTreeSettings* settings, |
53 OutputSurface* output_surface, | 68 OutputSurface* output_surface, |
54 ResourceProvider* resource_provider, | 69 ResourceProvider* resource_provider, |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
146 static bool IsDefaultBlendMode(SkXfermode::Mode blend_mode) { | 161 static bool IsDefaultBlendMode(SkXfermode::Mode blend_mode) { |
147 return blend_mode == SkXfermode::kSrcOver_Mode; | 162 return blend_mode == SkXfermode::kSrcOver_Mode; |
148 } | 163 } |
149 bool CanApplyBlendModeUsingBlendFunc(SkXfermode::Mode blend_mode); | 164 bool CanApplyBlendModeUsingBlendFunc(SkXfermode::Mode blend_mode); |
150 void ApplyBlendModeUsingBlendFunc(SkXfermode::Mode blend_mode); | 165 void ApplyBlendModeUsingBlendFunc(SkXfermode::Mode blend_mode); |
151 void RestoreBlendFuncToDefault(SkXfermode::Mode blend_mode); | 166 void RestoreBlendFuncToDefault(SkXfermode::Mode blend_mode); |
152 | 167 |
153 gfx::Rect GetBackdropBoundingBoxForRenderPassQuad( | 168 gfx::Rect GetBackdropBoundingBoxForRenderPassQuad( |
154 DrawingFrame* frame, | 169 DrawingFrame* frame, |
155 const RenderPassDrawQuad* quad, | 170 const RenderPassDrawQuad* quad, |
156 const gfx::Transform& contents_device_transform); | 171 const gfx::Transform& contents_device_transform, |
172 bool use_aa); | |
157 scoped_ptr<ScopedResource> GetBackdropTexture(const gfx::Rect& bounding_rect); | 173 scoped_ptr<ScopedResource> GetBackdropTexture(const gfx::Rect& bounding_rect); |
158 | 174 |
159 static bool ShouldApplyBackgroundFilters(DrawingFrame* frame, | 175 static bool ShouldApplyBackgroundFilters(DrawingFrame* frame, |
160 const RenderPassDrawQuad* quad); | 176 const RenderPassDrawQuad* quad); |
161 skia::RefPtr<SkImage> ApplyBackgroundFilters( | 177 skia::RefPtr<SkImage> ApplyBackgroundFilters( |
162 DrawingFrame* frame, | 178 DrawingFrame* frame, |
163 const RenderPassDrawQuad* quad, | 179 const RenderPassDrawQuad* quad, |
164 ScopedResource* background_texture); | 180 ScopedResource* background_texture); |
165 scoped_ptr<ScopedResource> ApplyInverseTransformForBackgroundFilters( | 181 scoped_ptr<ScopedResource> ApplyInverseTransformForBackgroundFilters( |
166 DrawingFrame* frame, | 182 DrawingFrame* frame, |
167 const RenderPassDrawQuad* quad, | 183 const RenderPassDrawQuad* quad, |
168 const gfx::Transform& contents_device_transform_inverse, | 184 const gfx::Transform& contents_device_transform_inverse, |
169 ScopedResource* background_texture, | |
170 skia::RefPtr<SkImage> backdrop_bitmap, | 185 skia::RefPtr<SkImage> backdrop_bitmap, |
171 const gfx::Rect& backdrop_bounding_rect); | 186 const gfx::Rect& backdrop_bounding_rect); |
172 | 187 |
173 void DrawRenderPassQuad(DrawingFrame* frame, const RenderPassDrawQuad* quad); | 188 void DrawRenderPassQuad(DrawingFrame* frame, const RenderPassDrawQuad* quad); |
174 void DrawSolidColorQuad(const DrawingFrame* frame, | 189 void DrawSolidColorQuad(const DrawingFrame* frame, |
175 const SolidColorDrawQuad* quad); | 190 const SolidColorDrawQuad* quad); |
176 void DrawStreamVideoQuad(const DrawingFrame* frame, | 191 void DrawStreamVideoQuad(const DrawingFrame* frame, |
177 const StreamVideoDrawQuad* quad); | 192 const StreamVideoDrawQuad* quad); |
178 void EnqueueTextureQuad(const DrawingFrame* frame, | 193 void EnqueueTextureQuad(const DrawingFrame* frame, |
179 const TextureDrawQuad* quad); | 194 const TextureDrawQuad* quad); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
321 TexCoordPrecision precision, SamplerType sampler); | 336 TexCoordPrecision precision, SamplerType sampler); |
322 const TileProgramSwizzle* GetTileProgramSwizzle( | 337 const TileProgramSwizzle* GetTileProgramSwizzle( |
323 TexCoordPrecision precision, SamplerType sampler); | 338 TexCoordPrecision precision, SamplerType sampler); |
324 const TileProgramSwizzleOpaque* GetTileProgramSwizzleOpaque( | 339 const TileProgramSwizzleOpaque* GetTileProgramSwizzleOpaque( |
325 TexCoordPrecision precision, SamplerType sampler); | 340 TexCoordPrecision precision, SamplerType sampler); |
326 const TileProgramSwizzleAA* GetTileProgramSwizzleAA( | 341 const TileProgramSwizzleAA* GetTileProgramSwizzleAA( |
327 TexCoordPrecision precision, SamplerType sampler); | 342 TexCoordPrecision precision, SamplerType sampler); |
328 | 343 |
329 const TileCheckerboardProgram* GetTileCheckerboardProgram(); | 344 const TileCheckerboardProgram* GetTileCheckerboardProgram(); |
330 | 345 |
331 const RenderPassProgram* GetRenderPassProgram( | 346 const RenderPassProgram* GetRenderPassProgram(TexCoordPrecision precision, |
332 TexCoordPrecision precision); | 347 SkXfermode::Mode blend_mode); |
333 const RenderPassProgramAA* GetRenderPassProgramAA( | 348 const RenderPassProgramAA* GetRenderPassProgramAA( |
334 TexCoordPrecision precision); | 349 TexCoordPrecision precision, |
350 SkXfermode::Mode blend_mode); | |
335 const RenderPassMaskProgram* GetRenderPassMaskProgram( | 351 const RenderPassMaskProgram* GetRenderPassMaskProgram( |
336 TexCoordPrecision precision); | 352 TexCoordPrecision precision, |
353 SkXfermode::Mode blend_mode); | |
337 const RenderPassMaskProgramAA* GetRenderPassMaskProgramAA( | 354 const RenderPassMaskProgramAA* GetRenderPassMaskProgramAA( |
338 TexCoordPrecision precision); | 355 TexCoordPrecision precision, |
356 SkXfermode::Mode blend_mode); | |
339 const RenderPassColorMatrixProgram* GetRenderPassColorMatrixProgram( | 357 const RenderPassColorMatrixProgram* GetRenderPassColorMatrixProgram( |
340 TexCoordPrecision precision); | 358 TexCoordPrecision precision, |
359 SkXfermode::Mode blend_mode); | |
341 const RenderPassColorMatrixProgramAA* GetRenderPassColorMatrixProgramAA( | 360 const RenderPassColorMatrixProgramAA* GetRenderPassColorMatrixProgramAA( |
342 TexCoordPrecision precision); | 361 TexCoordPrecision precision, |
362 SkXfermode::Mode blend_mode); | |
343 const RenderPassMaskColorMatrixProgram* GetRenderPassMaskColorMatrixProgram( | 363 const RenderPassMaskColorMatrixProgram* GetRenderPassMaskColorMatrixProgram( |
344 TexCoordPrecision precision); | 364 TexCoordPrecision precision, |
365 SkXfermode::Mode blend_mode); | |
345 const RenderPassMaskColorMatrixProgramAA* | 366 const RenderPassMaskColorMatrixProgramAA* |
346 GetRenderPassMaskColorMatrixProgramAA(TexCoordPrecision precision); | 367 GetRenderPassMaskColorMatrixProgramAA(TexCoordPrecision precision, |
368 SkXfermode::Mode blend_mode); | |
347 | 369 |
348 const TextureProgram* GetTextureProgram( | 370 const TextureProgram* GetTextureProgram( |
349 TexCoordPrecision precision); | 371 TexCoordPrecision precision); |
350 const NonPremultipliedTextureProgram* GetNonPremultipliedTextureProgram( | 372 const NonPremultipliedTextureProgram* GetNonPremultipliedTextureProgram( |
351 TexCoordPrecision precision); | 373 TexCoordPrecision precision); |
352 const TextureBackgroundProgram* GetTextureBackgroundProgram( | 374 const TextureBackgroundProgram* GetTextureBackgroundProgram( |
353 TexCoordPrecision precision); | 375 TexCoordPrecision precision); |
354 const NonPremultipliedTextureBackgroundProgram* | 376 const NonPremultipliedTextureBackgroundProgram* |
355 GetNonPremultipliedTextureBackgroundProgram(TexCoordPrecision precision); | 377 GetNonPremultipliedTextureBackgroundProgram(TexCoordPrecision precision); |
356 const TextureProgram* GetTextureIOSurfaceProgram( | 378 const TextureProgram* GetTextureIOSurfaceProgram( |
(...skipping 24 matching lines...) Expand all Loading... | |
381 TileCheckerboardProgram tile_checkerboard_program_; | 403 TileCheckerboardProgram tile_checkerboard_program_; |
382 | 404 |
383 TextureProgram texture_program_[NumTexCoordPrecisions]; | 405 TextureProgram texture_program_[NumTexCoordPrecisions]; |
384 NonPremultipliedTextureProgram | 406 NonPremultipliedTextureProgram |
385 nonpremultiplied_texture_program_[NumTexCoordPrecisions]; | 407 nonpremultiplied_texture_program_[NumTexCoordPrecisions]; |
386 TextureBackgroundProgram texture_background_program_[NumTexCoordPrecisions]; | 408 TextureBackgroundProgram texture_background_program_[NumTexCoordPrecisions]; |
387 NonPremultipliedTextureBackgroundProgram | 409 NonPremultipliedTextureBackgroundProgram |
388 nonpremultiplied_texture_background_program_[NumTexCoordPrecisions]; | 410 nonpremultiplied_texture_background_program_[NumTexCoordPrecisions]; |
389 TextureProgram texture_io_surface_program_[NumTexCoordPrecisions]; | 411 TextureProgram texture_io_surface_program_[NumTexCoordPrecisions]; |
390 | 412 |
391 RenderPassProgram render_pass_program_[NumTexCoordPrecisions]; | 413 RenderPassProgram render_pass_program_[NumTexCoordPrecisions][kNumBlendModes]; |
392 RenderPassProgramAA render_pass_program_aa_[NumTexCoordPrecisions]; | 414 RenderPassProgramAA |
393 RenderPassMaskProgram render_pass_mask_program_[NumTexCoordPrecisions]; | 415 render_pass_program_aa_[NumTexCoordPrecisions][kNumBlendModes]; |
394 RenderPassMaskProgramAA render_pass_mask_program_aa_[NumTexCoordPrecisions]; | 416 RenderPassMaskProgram |
417 render_pass_mask_program_[NumTexCoordPrecisions][kNumBlendModes]; | |
418 RenderPassMaskProgramAA | |
419 render_pass_mask_program_aa_[NumTexCoordPrecisions][kNumBlendModes]; | |
395 RenderPassColorMatrixProgram | 420 RenderPassColorMatrixProgram |
396 render_pass_color_matrix_program_[NumTexCoordPrecisions]; | 421 render_pass_color_matrix_program_[NumTexCoordPrecisions][kNumBlendModes]; |
397 RenderPassColorMatrixProgramAA | 422 RenderPassColorMatrixProgramAA render_pass_color_matrix_program_aa_ |
398 render_pass_color_matrix_program_aa_[NumTexCoordPrecisions]; | 423 [NumTexCoordPrecisions][kNumBlendModes]; |
399 RenderPassMaskColorMatrixProgram | 424 RenderPassMaskColorMatrixProgram render_pass_mask_color_matrix_program_ |
400 render_pass_mask_color_matrix_program_[NumTexCoordPrecisions]; | 425 [NumTexCoordPrecisions][kNumBlendModes]; |
401 RenderPassMaskColorMatrixProgramAA | 426 RenderPassMaskColorMatrixProgramAA render_pass_mask_color_matrix_program_aa_ |
402 render_pass_mask_color_matrix_program_aa_[NumTexCoordPrecisions]; | 427 [NumTexCoordPrecisions][kNumBlendModes]; |
403 | 428 |
404 VideoYUVProgram video_yuv_program_[NumTexCoordPrecisions]; | 429 VideoYUVProgram video_yuv_program_[NumTexCoordPrecisions]; |
405 VideoYUVAProgram video_yuva_program_[NumTexCoordPrecisions]; | 430 VideoYUVAProgram video_yuva_program_[NumTexCoordPrecisions]; |
406 VideoStreamTextureProgram | 431 VideoStreamTextureProgram |
407 video_stream_texture_program_[NumTexCoordPrecisions]; | 432 video_stream_texture_program_[NumTexCoordPrecisions]; |
408 | 433 |
409 DebugBorderProgram debug_border_program_; | 434 DebugBorderProgram debug_border_program_; |
410 SolidColorProgram solid_color_program_; | 435 SolidColorProgram solid_color_program_; |
411 SolidColorProgramAA solid_color_program_aa_; | 436 SolidColorProgramAA solid_color_program_aa_; |
412 | 437 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
455 #if DEBUG_GL_CALLS && !defined(NDEBUG) | 480 #if DEBUG_GL_CALLS && !defined(NDEBUG) |
456 #define GLC(context, x) \ | 481 #define GLC(context, x) \ |
457 (x, GLRenderer::DebugGLCall(&* context, #x, __FILE__, __LINE__)) | 482 (x, GLRenderer::DebugGLCall(&* context, #x, __FILE__, __LINE__)) |
458 #else | 483 #else |
459 #define GLC(context, x) (x) | 484 #define GLC(context, x) (x) |
460 #endif | 485 #endif |
461 | 486 |
462 } // namespace cc | 487 } // namespace cc |
463 | 488 |
464 #endif // CC_OUTPUT_GL_RENDERER_H_ | 489 #endif // CC_OUTPUT_GL_RENDERER_H_ |
OLD | NEW |