| 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 #include "cc/output/gl_renderer.h" | 5 #include "cc/output/gl_renderer.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| 11 #include <limits> | 11 #include <limits> |
| 12 #include <memory> |
| 12 #include <set> | 13 #include <set> |
| 13 #include <string> | 14 #include <string> |
| 14 #include <vector> | 15 #include <vector> |
| 15 | 16 |
| 16 #include "base/logging.h" | 17 #include "base/logging.h" |
| 17 #include "base/macros.h" | 18 #include "base/macros.h" |
| 18 #include "base/memory/scoped_ptr.h" | 19 #include "base/memory/ptr_util.h" |
| 19 #include "base/strings/string_split.h" | 20 #include "base/strings/string_split.h" |
| 20 #include "base/strings/string_util.h" | 21 #include "base/strings/string_util.h" |
| 21 #include "base/strings/stringprintf.h" | 22 #include "base/strings/stringprintf.h" |
| 22 #include "base/trace_event/trace_event.h" | 23 #include "base/trace_event/trace_event.h" |
| 23 #include "build/build_config.h" | 24 #include "build/build_config.h" |
| 24 #include "cc/base/container_util.h" | 25 #include "cc/base/container_util.h" |
| 25 #include "cc/base/math_util.h" | 26 #include "cc/base/math_util.h" |
| 26 #include "cc/output/compositor_frame.h" | 27 #include "cc/output/compositor_frame.h" |
| 27 #include "cc/output/compositor_frame_metadata.h" | 28 #include "cc/output/compositor_frame_metadata.h" |
| 28 #include "cc/output/context_provider.h" | 29 #include "cc/output/context_provider.h" |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 } // anonymous namespace | 152 } // anonymous namespace |
| 152 | 153 |
| 153 static GLint GetActiveTextureUnit(GLES2Interface* gl) { | 154 static GLint GetActiveTextureUnit(GLES2Interface* gl) { |
| 154 GLint active_unit = 0; | 155 GLint active_unit = 0; |
| 155 gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit); | 156 gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit); |
| 156 return active_unit; | 157 return active_unit; |
| 157 } | 158 } |
| 158 | 159 |
| 159 class GLRenderer::ScopedUseGrContext { | 160 class GLRenderer::ScopedUseGrContext { |
| 160 public: | 161 public: |
| 161 static scoped_ptr<ScopedUseGrContext> Create(GLRenderer* renderer, | 162 static std::unique_ptr<ScopedUseGrContext> Create(GLRenderer* renderer, |
| 162 DrawingFrame* frame) { | 163 DrawingFrame* frame) { |
| 163 // GrContext for filters is created lazily, and may fail if the context | 164 // GrContext for filters is created lazily, and may fail if the context |
| 164 // is lost. | 165 // is lost. |
| 165 // TODO(vmiura,bsalomon): crbug.com/487850 Ensure that | 166 // TODO(vmiura,bsalomon): crbug.com/487850 Ensure that |
| 166 // ContextProvider::GrContext() does not return NULL. | 167 // ContextProvider::GrContext() does not return NULL. |
| 167 if (renderer->output_surface_->context_provider()->GrContext()) | 168 if (renderer->output_surface_->context_provider()->GrContext()) |
| 168 return make_scoped_ptr(new ScopedUseGrContext(renderer, frame)); | 169 return base::WrapUnique(new ScopedUseGrContext(renderer, frame)); |
| 169 return nullptr; | 170 return nullptr; |
| 170 } | 171 } |
| 171 | 172 |
| 172 ~ScopedUseGrContext() { | 173 ~ScopedUseGrContext() { |
| 173 // Pass context control back to GLrenderer. | 174 // Pass context control back to GLrenderer. |
| 174 scoped_gpu_raster_ = nullptr; | 175 scoped_gpu_raster_ = nullptr; |
| 175 renderer_->RestoreGLState(); | 176 renderer_->RestoreGLState(); |
| 176 renderer_->RestoreFramebuffer(frame_); | 177 renderer_->RestoreFramebuffer(frame_); |
| 177 } | 178 } |
| 178 | 179 |
| 179 GrContext* context() const { | 180 GrContext* context() const { |
| 180 return renderer_->output_surface_->context_provider()->GrContext(); | 181 return renderer_->output_surface_->context_provider()->GrContext(); |
| 181 } | 182 } |
| 182 | 183 |
| 183 private: | 184 private: |
| 184 ScopedUseGrContext(GLRenderer* renderer, DrawingFrame* frame) | 185 ScopedUseGrContext(GLRenderer* renderer, DrawingFrame* frame) |
| 185 : scoped_gpu_raster_( | 186 : scoped_gpu_raster_( |
| 186 new ScopedGpuRaster(renderer->output_surface_->context_provider())), | 187 new ScopedGpuRaster(renderer->output_surface_->context_provider())), |
| 187 renderer_(renderer), | 188 renderer_(renderer), |
| 188 frame_(frame) { | 189 frame_(frame) { |
| 189 // scoped_gpu_raster_ passes context control to Skia. | 190 // scoped_gpu_raster_ passes context control to Skia. |
| 190 } | 191 } |
| 191 | 192 |
| 192 scoped_ptr<ScopedGpuRaster> scoped_gpu_raster_; | 193 std::unique_ptr<ScopedGpuRaster> scoped_gpu_raster_; |
| 193 GLRenderer* renderer_; | 194 GLRenderer* renderer_; |
| 194 DrawingFrame* frame_; | 195 DrawingFrame* frame_; |
| 195 | 196 |
| 196 DISALLOW_COPY_AND_ASSIGN(ScopedUseGrContext); | 197 DISALLOW_COPY_AND_ASSIGN(ScopedUseGrContext); |
| 197 }; | 198 }; |
| 198 | 199 |
| 199 struct GLRenderer::PendingAsyncReadPixels { | 200 struct GLRenderer::PendingAsyncReadPixels { |
| 200 PendingAsyncReadPixels() : buffer(0) {} | 201 PendingAsyncReadPixels() : buffer(0) {} |
| 201 | 202 |
| 202 scoped_ptr<CopyOutputRequest> copy_request; | 203 std::unique_ptr<CopyOutputRequest> copy_request; |
| 203 base::CancelableClosure finished_read_pixels_callback; | 204 base::CancelableClosure finished_read_pixels_callback; |
| 204 unsigned buffer; | 205 unsigned buffer; |
| 205 | 206 |
| 206 private: | 207 private: |
| 207 DISALLOW_COPY_AND_ASSIGN(PendingAsyncReadPixels); | 208 DISALLOW_COPY_AND_ASSIGN(PendingAsyncReadPixels); |
| 208 }; | 209 }; |
| 209 | 210 |
| 210 class GLRenderer::SyncQuery { | 211 class GLRenderer::SyncQuery { |
| 211 public: | 212 public: |
| 212 explicit SyncQuery(gpu::gles2::GLES2Interface* gl) | 213 explicit SyncQuery(gpu::gles2::GLES2Interface* gl) |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 }; | 293 }; |
| 293 | 294 |
| 294 gpu::gles2::GLES2Interface* gl_; | 295 gpu::gles2::GLES2Interface* gl_; |
| 295 unsigned query_id_; | 296 unsigned query_id_; |
| 296 bool is_pending_; | 297 bool is_pending_; |
| 297 base::WeakPtrFactory<SyncQuery> weak_ptr_factory_; | 298 base::WeakPtrFactory<SyncQuery> weak_ptr_factory_; |
| 298 | 299 |
| 299 DISALLOW_COPY_AND_ASSIGN(SyncQuery); | 300 DISALLOW_COPY_AND_ASSIGN(SyncQuery); |
| 300 }; | 301 }; |
| 301 | 302 |
| 302 scoped_ptr<GLRenderer> GLRenderer::Create( | 303 std::unique_ptr<GLRenderer> GLRenderer::Create( |
| 303 RendererClient* client, | 304 RendererClient* client, |
| 304 const RendererSettings* settings, | 305 const RendererSettings* settings, |
| 305 OutputSurface* output_surface, | 306 OutputSurface* output_surface, |
| 306 ResourceProvider* resource_provider, | 307 ResourceProvider* resource_provider, |
| 307 TextureMailboxDeleter* texture_mailbox_deleter, | 308 TextureMailboxDeleter* texture_mailbox_deleter, |
| 308 int highp_threshold_min) { | 309 int highp_threshold_min) { |
| 309 return make_scoped_ptr(new GLRenderer(client, | 310 return base::WrapUnique( |
| 310 settings, | 311 new GLRenderer(client, settings, output_surface, resource_provider, |
| 311 output_surface, | 312 texture_mailbox_deleter, highp_threshold_min)); |
| 312 resource_provider, | |
| 313 texture_mailbox_deleter, | |
| 314 highp_threshold_min)); | |
| 315 } | 313 } |
| 316 | 314 |
| 317 GLRenderer::GLRenderer(RendererClient* client, | 315 GLRenderer::GLRenderer(RendererClient* client, |
| 318 const RendererSettings* settings, | 316 const RendererSettings* settings, |
| 319 OutputSurface* output_surface, | 317 OutputSurface* output_surface, |
| 320 ResourceProvider* resource_provider, | 318 ResourceProvider* resource_provider, |
| 321 TextureMailboxDeleter* texture_mailbox_deleter, | 319 TextureMailboxDeleter* texture_mailbox_deleter, |
| 322 int highp_threshold_min) | 320 int highp_threshold_min) |
| 323 : DirectRenderer(client, settings, output_surface, resource_provider), | 321 : DirectRenderer(client, settings, output_surface, resource_provider), |
| 324 offscreen_framebuffer_id_(0), | 322 offscreen_framebuffer_id_(0), |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 } | 471 } |
| 474 | 472 |
| 475 while (!pending_sync_queries_.empty()) { | 473 while (!pending_sync_queries_.empty()) { |
| 476 if (pending_sync_queries_.front()->IsPending()) | 474 if (pending_sync_queries_.front()->IsPending()) |
| 477 break; | 475 break; |
| 478 | 476 |
| 479 available_sync_queries_.push_back(PopFront(&pending_sync_queries_)); | 477 available_sync_queries_.push_back(PopFront(&pending_sync_queries_)); |
| 480 } | 478 } |
| 481 | 479 |
| 482 current_sync_query_ = available_sync_queries_.empty() | 480 current_sync_query_ = available_sync_queries_.empty() |
| 483 ? make_scoped_ptr(new SyncQuery(gl_)) | 481 ? base::WrapUnique(new SyncQuery(gl_)) |
| 484 : PopFront(&available_sync_queries_); | 482 : PopFront(&available_sync_queries_); |
| 485 | 483 |
| 486 read_lock_fence = current_sync_query_->Begin(); | 484 read_lock_fence = current_sync_query_->Begin(); |
| 487 } else { | 485 } else { |
| 488 read_lock_fence = | 486 read_lock_fence = |
| 489 make_scoped_refptr(new ResourceProvider::SynchronousFence(gl_)); | 487 make_scoped_refptr(new ResourceProvider::SynchronousFence(gl_)); |
| 490 } | 488 } |
| 491 resource_provider_->SetReadLockFence(read_lock_fence.get()); | 489 resource_provider_->SetReadLockFence(read_lock_fence.get()); |
| 492 | 490 |
| 493 // Insert WaitSyncTokenCHROMIUM on quad resources prior to drawing the frame, | 491 // Insert WaitSyncTokenCHROMIUM on quad resources prior to drawing the frame, |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 (SkColorGetB(color) * (1.0f / 255.0f)) * alpha, alpha); | 589 (SkColorGetB(color) * (1.0f / 255.0f)) * alpha, alpha); |
| 592 | 590 |
| 593 gl_->LineWidth(quad->width); | 591 gl_->LineWidth(quad->width); |
| 594 | 592 |
| 595 // The indices for the line are stored in the same array as the triangle | 593 // The indices for the line are stored in the same array as the triangle |
| 596 // indices. | 594 // indices. |
| 597 gl_->DrawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_SHORT, 0); | 595 gl_->DrawElements(GL_LINE_LOOP, 4, GL_UNSIGNED_SHORT, 0); |
| 598 } | 596 } |
| 599 | 597 |
| 600 static skia::RefPtr<SkImage> ApplyImageFilter( | 598 static skia::RefPtr<SkImage> ApplyImageFilter( |
| 601 scoped_ptr<GLRenderer::ScopedUseGrContext> use_gr_context, | 599 std::unique_ptr<GLRenderer::ScopedUseGrContext> use_gr_context, |
| 602 ResourceProvider* resource_provider, | 600 ResourceProvider* resource_provider, |
| 603 const gfx::RectF& src_rect, | 601 const gfx::RectF& src_rect, |
| 604 const gfx::RectF& dst_rect, | 602 const gfx::RectF& dst_rect, |
| 605 const gfx::Vector2dF& scale, | 603 const gfx::Vector2dF& scale, |
| 606 SkImageFilter* filter, | 604 SkImageFilter* filter, |
| 607 ScopedResource* source_texture_resource) { | 605 ScopedResource* source_texture_resource) { |
| 608 if (!filter) | 606 if (!filter) |
| 609 return skia::RefPtr<SkImage>(); | 607 return skia::RefPtr<SkImage>(); |
| 610 | 608 |
| 611 if (!use_gr_context) | 609 if (!use_gr_context) |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 // background, so texture edge clamping gives us a transparent border | 826 // background, so texture edge clamping gives us a transparent border |
| 829 // in case the filter expands the result. | 827 // in case the filter expands the result. |
| 830 backdrop_rect.Inset(-1, -1, -1, -1); | 828 backdrop_rect.Inset(-1, -1, -1, -1); |
| 831 } | 829 } |
| 832 | 830 |
| 833 backdrop_rect.Intersect(MoveFromDrawToWindowSpace( | 831 backdrop_rect.Intersect(MoveFromDrawToWindowSpace( |
| 834 frame, frame->current_render_pass->output_rect)); | 832 frame, frame->current_render_pass->output_rect)); |
| 835 return backdrop_rect; | 833 return backdrop_rect; |
| 836 } | 834 } |
| 837 | 835 |
| 838 scoped_ptr<ScopedResource> GLRenderer::GetBackdropTexture( | 836 std::unique_ptr<ScopedResource> GLRenderer::GetBackdropTexture( |
| 839 const gfx::Rect& bounding_rect) { | 837 const gfx::Rect& bounding_rect) { |
| 840 scoped_ptr<ScopedResource> device_background_texture = | 838 std::unique_ptr<ScopedResource> device_background_texture = |
| 841 ScopedResource::Create(resource_provider_); | 839 ScopedResource::Create(resource_provider_); |
| 842 // CopyTexImage2D fails when called on a texture having immutable storage. | 840 // CopyTexImage2D fails when called on a texture having immutable storage. |
| 843 device_background_texture->Allocate( | 841 device_background_texture->Allocate( |
| 844 bounding_rect.size(), ResourceProvider::TEXTURE_HINT_DEFAULT, | 842 bounding_rect.size(), ResourceProvider::TEXTURE_HINT_DEFAULT, |
| 845 resource_provider_->best_texture_format()); | 843 resource_provider_->best_texture_format()); |
| 846 { | 844 { |
| 847 ResourceProvider::ScopedWriteLockGL lock(resource_provider_, | 845 ResourceProvider::ScopedWriteLockGL lock(resource_provider_, |
| 848 device_background_texture->id()); | 846 device_background_texture->id()); |
| 849 GetFramebufferTexture(lock.texture_id(), RGBA_8888, bounding_rect); | 847 GetFramebufferTexture(lock.texture_id(), RGBA_8888, bounding_rect); |
| 850 } | 848 } |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 920 const gfx::QuadF* aa_quad = use_aa ? &device_layer_quad : nullptr; | 918 const gfx::QuadF* aa_quad = use_aa ? &device_layer_quad : nullptr; |
| 921 SetupRenderPassQuadForClippingAndAntialiasing(contents_device_transform, quad, | 919 SetupRenderPassQuadForClippingAndAntialiasing(contents_device_transform, quad, |
| 922 aa_quad, clip_region, | 920 aa_quad, clip_region, |
| 923 &surface_quad, edge); | 921 &surface_quad, edge); |
| 924 SkXfermode::Mode blend_mode = quad->shared_quad_state->blend_mode; | 922 SkXfermode::Mode blend_mode = quad->shared_quad_state->blend_mode; |
| 925 bool use_shaders_for_blending = | 923 bool use_shaders_for_blending = |
| 926 !CanApplyBlendModeUsingBlendFunc(blend_mode) || | 924 !CanApplyBlendModeUsingBlendFunc(blend_mode) || |
| 927 ShouldApplyBackgroundFilters(quad) || | 925 ShouldApplyBackgroundFilters(quad) || |
| 928 settings_->force_blending_with_shaders; | 926 settings_->force_blending_with_shaders; |
| 929 | 927 |
| 930 scoped_ptr<ScopedResource> background_texture; | 928 std::unique_ptr<ScopedResource> background_texture; |
| 931 skia::RefPtr<SkImage> background_image; | 929 skia::RefPtr<SkImage> background_image; |
| 932 GLuint background_image_id = 0; | 930 GLuint background_image_id = 0; |
| 933 gfx::Rect background_rect; | 931 gfx::Rect background_rect; |
| 934 if (use_shaders_for_blending) { | 932 if (use_shaders_for_blending) { |
| 935 // Compute a bounding box around the pixels that will be visible through | 933 // Compute a bounding box around the pixels that will be visible through |
| 936 // the quad. | 934 // the quad. |
| 937 background_rect = GetBackdropBoundingBoxForRenderPassQuad( | 935 background_rect = GetBackdropBoundingBoxForRenderPassQuad( |
| 938 frame, quad, contents_device_transform, clip_region, use_aa); | 936 frame, quad, contents_device_transform, clip_region, use_aa); |
| 939 | 937 |
| 940 if (!background_rect.IsEmpty()) { | 938 if (!background_rect.IsEmpty()) { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1034 filter_image_id = skia::GrBackendObjectToGrGLTextureInfo( | 1032 filter_image_id = skia::GrBackendObjectToGrGLTextureInfo( |
| 1035 filter_image->getTextureHandle(true)) | 1033 filter_image->getTextureHandle(true)) |
| 1036 ->fID; | 1034 ->fID; |
| 1037 DCHECK(filter_image_id); | 1035 DCHECK(filter_image_id); |
| 1038 rect = dst_rect; | 1036 rect = dst_rect; |
| 1039 } | 1037 } |
| 1040 } | 1038 } |
| 1041 } | 1039 } |
| 1042 } | 1040 } |
| 1043 | 1041 |
| 1044 scoped_ptr<ResourceProvider::ScopedSamplerGL> mask_resource_lock; | 1042 std::unique_ptr<ResourceProvider::ScopedSamplerGL> mask_resource_lock; |
| 1045 unsigned mask_texture_id = 0; | 1043 unsigned mask_texture_id = 0; |
| 1046 SamplerType mask_sampler = SAMPLER_TYPE_NA; | 1044 SamplerType mask_sampler = SAMPLER_TYPE_NA; |
| 1047 if (quad->mask_resource_id()) { | 1045 if (quad->mask_resource_id()) { |
| 1048 mask_resource_lock.reset(new ResourceProvider::ScopedSamplerGL( | 1046 mask_resource_lock.reset(new ResourceProvider::ScopedSamplerGL( |
| 1049 resource_provider_, quad->mask_resource_id(), GL_TEXTURE1, GL_LINEAR)); | 1047 resource_provider_, quad->mask_resource_id(), GL_TEXTURE1, GL_LINEAR)); |
| 1050 mask_texture_id = mask_resource_lock->texture_id(); | 1048 mask_texture_id = mask_resource_lock->texture_id(); |
| 1051 mask_sampler = SamplerTypeFromTextureTarget(mask_resource_lock->target()); | 1049 mask_sampler = SamplerTypeFromTextureTarget(mask_resource_lock->target()); |
| 1052 } | 1050 } |
| 1053 | 1051 |
| 1054 scoped_ptr<ResourceProvider::ScopedSamplerGL> contents_resource_lock; | 1052 std::unique_ptr<ResourceProvider::ScopedSamplerGL> contents_resource_lock; |
| 1055 if (filter_image_id) { | 1053 if (filter_image_id) { |
| 1056 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_)); | 1054 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_)); |
| 1057 gl_->BindTexture(GL_TEXTURE_2D, filter_image_id); | 1055 gl_->BindTexture(GL_TEXTURE_2D, filter_image_id); |
| 1058 } else { | 1056 } else { |
| 1059 contents_resource_lock = | 1057 contents_resource_lock = |
| 1060 make_scoped_ptr(new ResourceProvider::ScopedSamplerGL( | 1058 base::WrapUnique(new ResourceProvider::ScopedSamplerGL( |
| 1061 resource_provider_, contents_texture->id(), GL_LINEAR)); | 1059 resource_provider_, contents_texture->id(), GL_LINEAR)); |
| 1062 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), | 1060 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), |
| 1063 contents_resource_lock->target()); | 1061 contents_resource_lock->target()); |
| 1064 } | 1062 } |
| 1065 | 1063 |
| 1066 if (!use_shaders_for_blending) { | 1064 if (!use_shaders_for_blending) { |
| 1067 if (!use_blend_equation_advanced_coherent_ && use_blend_equation_advanced_) | 1065 if (!use_blend_equation_advanced_coherent_ && use_blend_equation_advanced_) |
| 1068 gl_->BlendBarrierKHR(); | 1066 gl_->BlendBarrierKHR(); |
| 1069 | 1067 |
| 1070 ApplyBlendModeUsingBlendFunc(blend_mode); | 1068 ApplyBlendModeUsingBlendFunc(blend_mode); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1213 } | 1211 } |
| 1214 static const float kScale = 1.0f / 255.0f; | 1212 static const float kScale = 1.0f / 255.0f; |
| 1215 if (locations.color_offset != -1) { | 1213 if (locations.color_offset != -1) { |
| 1216 float offset[4]; | 1214 float offset[4]; |
| 1217 for (int i = 0; i < 4; ++i) | 1215 for (int i = 0; i < 4; ++i) |
| 1218 offset[i] = SkScalarToFloat(color_matrix[i * 5 + 4]) * kScale; | 1216 offset[i] = SkScalarToFloat(color_matrix[i * 5 + 4]) * kScale; |
| 1219 | 1217 |
| 1220 gl_->Uniform4fv(locations.color_offset, 1, offset); | 1218 gl_->Uniform4fv(locations.color_offset, 1, offset); |
| 1221 } | 1219 } |
| 1222 | 1220 |
| 1223 scoped_ptr<ResourceProvider::ScopedSamplerGL> shader_background_sampler_lock; | 1221 std::unique_ptr<ResourceProvider::ScopedSamplerGL> |
| 1222 shader_background_sampler_lock; |
| 1224 if (locations.backdrop != -1) { | 1223 if (locations.backdrop != -1) { |
| 1225 DCHECK(background_texture || background_image_id); | 1224 DCHECK(background_texture || background_image_id); |
| 1226 DCHECK_NE(locations.backdrop, 0); | 1225 DCHECK_NE(locations.backdrop, 0); |
| 1227 DCHECK_NE(locations.backdrop_rect, 0); | 1226 DCHECK_NE(locations.backdrop_rect, 0); |
| 1228 | 1227 |
| 1229 gl_->Uniform1i(locations.backdrop, ++last_texture_unit); | 1228 gl_->Uniform1i(locations.backdrop, ++last_texture_unit); |
| 1230 | 1229 |
| 1231 gl_->Uniform4f(locations.backdrop_rect, background_rect.x(), | 1230 gl_->Uniform4f(locations.backdrop_rect, background_rect.x(), |
| 1232 background_rect.y(), background_rect.width(), | 1231 background_rect.y(), background_rect.width(), |
| 1233 background_rect.height()); | 1232 background_rect.height()); |
| 1234 | 1233 |
| 1235 if (background_image_id) { | 1234 if (background_image_id) { |
| 1236 gl_->ActiveTexture(GL_TEXTURE0 + last_texture_unit); | 1235 gl_->ActiveTexture(GL_TEXTURE0 + last_texture_unit); |
| 1237 gl_->BindTexture(GL_TEXTURE_2D, background_image_id); | 1236 gl_->BindTexture(GL_TEXTURE_2D, background_image_id); |
| 1238 gl_->ActiveTexture(GL_TEXTURE0); | 1237 gl_->ActiveTexture(GL_TEXTURE0); |
| 1239 if (mask_for_background) | 1238 if (mask_for_background) |
| 1240 gl_->Uniform1i(locations.original_backdrop, ++last_texture_unit); | 1239 gl_->Uniform1i(locations.original_backdrop, ++last_texture_unit); |
| 1241 } | 1240 } |
| 1242 if (background_texture) { | 1241 if (background_texture) { |
| 1243 shader_background_sampler_lock = make_scoped_ptr( | 1242 shader_background_sampler_lock = |
| 1244 new ResourceProvider::ScopedSamplerGL(resource_provider_, | 1243 base::WrapUnique(new ResourceProvider::ScopedSamplerGL( |
| 1245 background_texture->id(), | 1244 resource_provider_, background_texture->id(), |
| 1246 GL_TEXTURE0 + last_texture_unit, | 1245 GL_TEXTURE0 + last_texture_unit, GL_LINEAR)); |
| 1247 GL_LINEAR)); | |
| 1248 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), | 1246 DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), |
| 1249 shader_background_sampler_lock->target()); | 1247 shader_background_sampler_lock->target()); |
| 1250 } | 1248 } |
| 1251 } | 1249 } |
| 1252 | 1250 |
| 1253 SetShaderOpacity(quad->shared_quad_state->opacity, locations.alpha); | 1251 SetShaderOpacity(quad->shared_quad_state->opacity, locations.alpha); |
| 1254 SetShaderQuadF(surface_quad, locations.quad); | 1252 SetShaderQuadF(surface_quad, locations.quad); |
| 1255 DrawQuadGeometry(frame, quad->shared_quad_state->quad_to_target_transform, | 1253 DrawQuadGeometry(frame, quad->shared_quad_state->quad_to_target_transform, |
| 1256 rect, locations.matrix); | 1254 rect, locations.matrix); |
| 1257 | 1255 |
| (...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1961 bool use_alpha_plane = quad->a_plane_resource_id() != 0; | 1959 bool use_alpha_plane = quad->a_plane_resource_id() != 0; |
| 1962 | 1960 |
| 1963 ResourceProvider::ScopedSamplerGL y_plane_lock( | 1961 ResourceProvider::ScopedSamplerGL y_plane_lock( |
| 1964 resource_provider_, quad->y_plane_resource_id(), GL_TEXTURE1, GL_LINEAR); | 1962 resource_provider_, quad->y_plane_resource_id(), GL_TEXTURE1, GL_LINEAR); |
| 1965 ResourceProvider::ScopedSamplerGL u_plane_lock( | 1963 ResourceProvider::ScopedSamplerGL u_plane_lock( |
| 1966 resource_provider_, quad->u_plane_resource_id(), GL_TEXTURE2, GL_LINEAR); | 1964 resource_provider_, quad->u_plane_resource_id(), GL_TEXTURE2, GL_LINEAR); |
| 1967 DCHECK_EQ(y_plane_lock.target(), u_plane_lock.target()); | 1965 DCHECK_EQ(y_plane_lock.target(), u_plane_lock.target()); |
| 1968 ResourceProvider::ScopedSamplerGL v_plane_lock( | 1966 ResourceProvider::ScopedSamplerGL v_plane_lock( |
| 1969 resource_provider_, quad->v_plane_resource_id(), GL_TEXTURE3, GL_LINEAR); | 1967 resource_provider_, quad->v_plane_resource_id(), GL_TEXTURE3, GL_LINEAR); |
| 1970 DCHECK_EQ(y_plane_lock.target(), v_plane_lock.target()); | 1968 DCHECK_EQ(y_plane_lock.target(), v_plane_lock.target()); |
| 1971 scoped_ptr<ResourceProvider::ScopedSamplerGL> a_plane_lock; | 1969 std::unique_ptr<ResourceProvider::ScopedSamplerGL> a_plane_lock; |
| 1972 if (use_alpha_plane) { | 1970 if (use_alpha_plane) { |
| 1973 a_plane_lock.reset(new ResourceProvider::ScopedSamplerGL( | 1971 a_plane_lock.reset(new ResourceProvider::ScopedSamplerGL( |
| 1974 resource_provider_, quad->a_plane_resource_id(), GL_TEXTURE4, | 1972 resource_provider_, quad->a_plane_resource_id(), GL_TEXTURE4, |
| 1975 GL_LINEAR)); | 1973 GL_LINEAR)); |
| 1976 DCHECK_EQ(y_plane_lock.target(), a_plane_lock->target()); | 1974 DCHECK_EQ(y_plane_lock.target(), a_plane_lock->target()); |
| 1977 } | 1975 } |
| 1978 | 1976 |
| 1979 // All planes must have the same sampler type. | 1977 // All planes must have the same sampler type. |
| 1980 SamplerType sampler = SamplerTypeFromTextureTarget(y_plane_lock.target()); | 1978 SamplerType sampler = SamplerTypeFromTextureTarget(y_plane_lock.target()); |
| 1981 | 1979 |
| (...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2535 if (!is_scissor_enabled_) | 2533 if (!is_scissor_enabled_) |
| 2536 return; | 2534 return; |
| 2537 | 2535 |
| 2538 FlushTextureQuadCache(SHARED_BINDING); | 2536 FlushTextureQuadCache(SHARED_BINDING); |
| 2539 gl_->Disable(GL_SCISSOR_TEST); | 2537 gl_->Disable(GL_SCISSOR_TEST); |
| 2540 is_scissor_enabled_ = false; | 2538 is_scissor_enabled_ = false; |
| 2541 } | 2539 } |
| 2542 | 2540 |
| 2543 void GLRenderer::CopyCurrentRenderPassToBitmap( | 2541 void GLRenderer::CopyCurrentRenderPassToBitmap( |
| 2544 DrawingFrame* frame, | 2542 DrawingFrame* frame, |
| 2545 scoped_ptr<CopyOutputRequest> request) { | 2543 std::unique_ptr<CopyOutputRequest> request) { |
| 2546 TRACE_EVENT0("cc", "GLRenderer::CopyCurrentRenderPassToBitmap"); | 2544 TRACE_EVENT0("cc", "GLRenderer::CopyCurrentRenderPassToBitmap"); |
| 2547 gfx::Rect copy_rect = frame->current_render_pass->output_rect; | 2545 gfx::Rect copy_rect = frame->current_render_pass->output_rect; |
| 2548 if (request->has_area()) | 2546 if (request->has_area()) |
| 2549 copy_rect.Intersect(request->area()); | 2547 copy_rect.Intersect(request->area()); |
| 2550 GetFramebufferPixelsAsync(frame, copy_rect, std::move(request)); | 2548 GetFramebufferPixelsAsync(frame, copy_rect, std::move(request)); |
| 2551 } | 2549 } |
| 2552 | 2550 |
| 2553 void GLRenderer::ToGLMatrix(float* gl_matrix, const gfx::Transform& transform) { | 2551 void GLRenderer::ToGLMatrix(float* gl_matrix, const gfx::Transform& transform) { |
| 2554 transform.matrix().asColMajorf(gl_matrix); | 2552 transform.matrix().asColMajorf(gl_matrix); |
| 2555 } | 2553 } |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2649 void GLRenderer::SwapBuffers(const CompositorFrameMetadata& metadata) { | 2647 void GLRenderer::SwapBuffers(const CompositorFrameMetadata& metadata) { |
| 2650 DCHECK(!is_backbuffer_discarded_); | 2648 DCHECK(!is_backbuffer_discarded_); |
| 2651 | 2649 |
| 2652 TRACE_EVENT0("cc,benchmark", "GLRenderer::SwapBuffers"); | 2650 TRACE_EVENT0("cc,benchmark", "GLRenderer::SwapBuffers"); |
| 2653 // We're done! Time to swapbuffers! | 2651 // We're done! Time to swapbuffers! |
| 2654 | 2652 |
| 2655 gfx::Size surface_size = output_surface_->SurfaceSize(); | 2653 gfx::Size surface_size = output_surface_->SurfaceSize(); |
| 2656 | 2654 |
| 2657 CompositorFrame compositor_frame; | 2655 CompositorFrame compositor_frame; |
| 2658 compositor_frame.metadata = metadata; | 2656 compositor_frame.metadata = metadata; |
| 2659 compositor_frame.gl_frame_data = make_scoped_ptr(new GLFrameData); | 2657 compositor_frame.gl_frame_data = base::WrapUnique(new GLFrameData); |
| 2660 compositor_frame.gl_frame_data->size = surface_size; | 2658 compositor_frame.gl_frame_data->size = surface_size; |
| 2661 if (capabilities_.using_partial_swap) { | 2659 if (capabilities_.using_partial_swap) { |
| 2662 // If supported, we can save significant bandwidth by only swapping the | 2660 // If supported, we can save significant bandwidth by only swapping the |
| 2663 // damaged/scissored region (clamped to the viewport). | 2661 // damaged/scissored region (clamped to the viewport). |
| 2664 swap_buffer_rect_.Intersect(gfx::Rect(surface_size)); | 2662 swap_buffer_rect_.Intersect(gfx::Rect(surface_size)); |
| 2665 int flipped_y_pos_of_rect_bottom = surface_size.height() - | 2663 int flipped_y_pos_of_rect_bottom = surface_size.height() - |
| 2666 swap_buffer_rect_.y() - | 2664 swap_buffer_rect_.y() - |
| 2667 swap_buffer_rect_.height(); | 2665 swap_buffer_rect_.height(); |
| 2668 compositor_frame.gl_frame_data->sub_buffer_rect = | 2666 compositor_frame.gl_frame_data->sub_buffer_rect = |
| 2669 gfx::Rect(swap_buffer_rect_.x(), | 2667 gfx::Rect(swap_buffer_rect_.x(), |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2725 if (!is_backbuffer_discarded_) | 2723 if (!is_backbuffer_discarded_) |
| 2726 return; | 2724 return; |
| 2727 | 2725 |
| 2728 output_surface_->EnsureBackbuffer(); | 2726 output_surface_->EnsureBackbuffer(); |
| 2729 is_backbuffer_discarded_ = false; | 2727 is_backbuffer_discarded_ = false; |
| 2730 } | 2728 } |
| 2731 | 2729 |
| 2732 void GLRenderer::GetFramebufferPixelsAsync( | 2730 void GLRenderer::GetFramebufferPixelsAsync( |
| 2733 const DrawingFrame* frame, | 2731 const DrawingFrame* frame, |
| 2734 const gfx::Rect& rect, | 2732 const gfx::Rect& rect, |
| 2735 scoped_ptr<CopyOutputRequest> request) { | 2733 std::unique_ptr<CopyOutputRequest> request) { |
| 2736 DCHECK(!request->IsEmpty()); | 2734 DCHECK(!request->IsEmpty()); |
| 2737 if (request->IsEmpty()) | 2735 if (request->IsEmpty()) |
| 2738 return; | 2736 return; |
| 2739 if (rect.IsEmpty()) | 2737 if (rect.IsEmpty()) |
| 2740 return; | 2738 return; |
| 2741 | 2739 |
| 2742 gfx::Rect window_rect = MoveFromDrawToWindowSpace(frame, rect); | 2740 gfx::Rect window_rect = MoveFromDrawToWindowSpace(frame, rect); |
| 2743 DCHECK_GE(window_rect.x(), 0); | 2741 DCHECK_GE(window_rect.x(), 0); |
| 2744 DCHECK_GE(window_rect.y(), 0); | 2742 DCHECK_GE(window_rect.y(), 0); |
| 2745 DCHECK_LE(window_rect.right(), current_surface_size_.width()); | 2743 DCHECK_LE(window_rect.right(), current_surface_size_.width()); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 2776 GetFramebufferTexture(texture_id, RGBA_8888, window_rect); | 2774 GetFramebufferTexture(texture_id, RGBA_8888, window_rect); |
| 2777 | 2775 |
| 2778 const GLuint64 fence_sync = gl_->InsertFenceSyncCHROMIUM(); | 2776 const GLuint64 fence_sync = gl_->InsertFenceSyncCHROMIUM(); |
| 2779 gl_->ShallowFlushCHROMIUM(); | 2777 gl_->ShallowFlushCHROMIUM(); |
| 2780 | 2778 |
| 2781 gpu::SyncToken sync_token; | 2779 gpu::SyncToken sync_token; |
| 2782 gl_->GenSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); | 2780 gl_->GenSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); |
| 2783 | 2781 |
| 2784 TextureMailbox texture_mailbox(mailbox, sync_token, GL_TEXTURE_2D); | 2782 TextureMailbox texture_mailbox(mailbox, sync_token, GL_TEXTURE_2D); |
| 2785 | 2783 |
| 2786 scoped_ptr<SingleReleaseCallback> release_callback; | 2784 std::unique_ptr<SingleReleaseCallback> release_callback; |
| 2787 if (own_mailbox) { | 2785 if (own_mailbox) { |
| 2788 gl_->BindTexture(GL_TEXTURE_2D, 0); | 2786 gl_->BindTexture(GL_TEXTURE_2D, 0); |
| 2789 release_callback = texture_mailbox_deleter_->GetReleaseCallback( | 2787 release_callback = texture_mailbox_deleter_->GetReleaseCallback( |
| 2790 output_surface_->context_provider(), texture_id); | 2788 output_surface_->context_provider(), texture_id); |
| 2791 } else { | 2789 } else { |
| 2792 gl_->DeleteTextures(1, &texture_id); | 2790 gl_->DeleteTextures(1, &texture_id); |
| 2793 } | 2791 } |
| 2794 | 2792 |
| 2795 request->SendTextureResult(window_rect.size(), texture_mailbox, | 2793 request->SendTextureResult(window_rect.size(), texture_mailbox, |
| 2796 std::move(release_callback)); | 2794 std::move(release_callback)); |
| 2797 return; | 2795 return; |
| 2798 } | 2796 } |
| 2799 | 2797 |
| 2800 DCHECK(request->force_bitmap_result()); | 2798 DCHECK(request->force_bitmap_result()); |
| 2801 | 2799 |
| 2802 scoped_ptr<PendingAsyncReadPixels> pending_read(new PendingAsyncReadPixels); | 2800 std::unique_ptr<PendingAsyncReadPixels> pending_read( |
| 2801 new PendingAsyncReadPixels); |
| 2803 pending_read->copy_request = std::move(request); | 2802 pending_read->copy_request = std::move(request); |
| 2804 pending_async_read_pixels_.insert(pending_async_read_pixels_.begin(), | 2803 pending_async_read_pixels_.insert(pending_async_read_pixels_.begin(), |
| 2805 std::move(pending_read)); | 2804 std::move(pending_read)); |
| 2806 | 2805 |
| 2807 GLuint buffer = 0; | 2806 GLuint buffer = 0; |
| 2808 gl_->GenBuffers(1, &buffer); | 2807 gl_->GenBuffers(1, &buffer); |
| 2809 gl_->BindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, buffer); | 2808 gl_->BindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, buffer); |
| 2810 gl_->BufferData(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, | 2809 gl_->BufferData(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, |
| 2811 4 * window_rect.size().GetArea(), NULL, GL_STREAM_READ); | 2810 4 * window_rect.size().GetArea(), NULL, GL_STREAM_READ); |
| 2812 | 2811 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2856 // start searching from back to the front. | 2855 // start searching from back to the front. |
| 2857 auto iter = pending_async_read_pixels_.rbegin(); | 2856 auto iter = pending_async_read_pixels_.rbegin(); |
| 2858 const auto& reverse_end = pending_async_read_pixels_.rend(); | 2857 const auto& reverse_end = pending_async_read_pixels_.rend(); |
| 2859 while (iter != reverse_end && (*iter)->buffer != source_buffer) | 2858 while (iter != reverse_end && (*iter)->buffer != source_buffer) |
| 2860 ++iter; | 2859 ++iter; |
| 2861 | 2860 |
| 2862 DCHECK(iter != reverse_end); | 2861 DCHECK(iter != reverse_end); |
| 2863 PendingAsyncReadPixels* current_read = iter->get(); | 2862 PendingAsyncReadPixels* current_read = iter->get(); |
| 2864 | 2863 |
| 2865 uint8_t* src_pixels = NULL; | 2864 uint8_t* src_pixels = NULL; |
| 2866 scoped_ptr<SkBitmap> bitmap; | 2865 std::unique_ptr<SkBitmap> bitmap; |
| 2867 | 2866 |
| 2868 if (source_buffer != 0) { | 2867 if (source_buffer != 0) { |
| 2869 gl_->BindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, source_buffer); | 2868 gl_->BindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, source_buffer); |
| 2870 src_pixels = static_cast<uint8_t*>(gl_->MapBufferCHROMIUM( | 2869 src_pixels = static_cast<uint8_t*>(gl_->MapBufferCHROMIUM( |
| 2871 GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, GL_READ_ONLY)); | 2870 GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, GL_READ_ONLY)); |
| 2872 | 2871 |
| 2873 if (src_pixels) { | 2872 if (src_pixels) { |
| 2874 bitmap.reset(new SkBitmap); | 2873 bitmap.reset(new SkBitmap); |
| 2875 bitmap->allocN32Pixels(size.width(), size.height()); | 2874 bitmap->allocN32Pixels(size.width(), size.height()); |
| 2876 scoped_ptr<SkAutoLockPixels> lock(new SkAutoLockPixels(*bitmap)); | 2875 std::unique_ptr<SkAutoLockPixels> lock(new SkAutoLockPixels(*bitmap)); |
| 2877 uint8_t* dest_pixels = static_cast<uint8_t*>(bitmap->getPixels()); | 2876 uint8_t* dest_pixels = static_cast<uint8_t*>(bitmap->getPixels()); |
| 2878 | 2877 |
| 2879 size_t row_bytes = size.width() * 4; | 2878 size_t row_bytes = size.width() * 4; |
| 2880 int num_rows = size.height(); | 2879 int num_rows = size.height(); |
| 2881 size_t total_bytes = num_rows * row_bytes; | 2880 size_t total_bytes = num_rows * row_bytes; |
| 2882 for (size_t dest_y = 0; dest_y < total_bytes; dest_y += row_bytes) { | 2881 for (size_t dest_y = 0; dest_y < total_bytes; dest_y += row_bytes) { |
| 2883 // Flip Y axis. | 2882 // Flip Y axis. |
| 2884 size_t src_y = total_bytes - dest_y - row_bytes; | 2883 size_t src_y = total_bytes - dest_y - row_bytes; |
| 2885 // Swizzle OpenGL -> Skia byte order. | 2884 // Swizzle OpenGL -> Skia byte order. |
| 2886 for (size_t x = 0; x < row_bytes; x += 4) { | 2885 for (size_t x = 0; x < row_bytes; x += 4) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2943 const ScopedResource* texture) { | 2942 const ScopedResource* texture) { |
| 2944 DCHECK(texture->id()); | 2943 DCHECK(texture->id()); |
| 2945 | 2944 |
| 2946 // Explicitly release lock, otherwise we can crash when try to lock | 2945 // Explicitly release lock, otherwise we can crash when try to lock |
| 2947 // same texture again. | 2946 // same texture again. |
| 2948 current_framebuffer_lock_ = nullptr; | 2947 current_framebuffer_lock_ = nullptr; |
| 2949 | 2948 |
| 2950 SetStencilEnabled(false); | 2949 SetStencilEnabled(false); |
| 2951 gl_->BindFramebuffer(GL_FRAMEBUFFER, offscreen_framebuffer_id_); | 2950 gl_->BindFramebuffer(GL_FRAMEBUFFER, offscreen_framebuffer_id_); |
| 2952 current_framebuffer_lock_ = | 2951 current_framebuffer_lock_ = |
| 2953 make_scoped_ptr(new ResourceProvider::ScopedWriteLockGL( | 2952 base::WrapUnique(new ResourceProvider::ScopedWriteLockGL( |
| 2954 resource_provider_, texture->id())); | 2953 resource_provider_, texture->id())); |
| 2955 unsigned texture_id = current_framebuffer_lock_->texture_id(); | 2954 unsigned texture_id = current_framebuffer_lock_->texture_id(); |
| 2956 gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, | 2955 gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
| 2957 texture_id, 0); | 2956 texture_id, 0); |
| 2958 | 2957 |
| 2959 DCHECK(gl_->CheckFramebufferStatus(GL_FRAMEBUFFER) == | 2958 DCHECK(gl_->CheckFramebufferStatus(GL_FRAMEBUFFER) == |
| 2960 GL_FRAMEBUFFER_COMPLETE || | 2959 GL_FRAMEBUFFER_COMPLETE || |
| 2961 IsContextLost()); | 2960 IsContextLost()); |
| 2962 return true; | 2961 return true; |
| 2963 } | 2962 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2985 current_window_space_viewport_.height()); | 2984 current_window_space_viewport_.height()); |
| 2986 } | 2985 } |
| 2987 | 2986 |
| 2988 void GLRenderer::InitializeSharedObjects() { | 2987 void GLRenderer::InitializeSharedObjects() { |
| 2989 TRACE_EVENT0("cc", "GLRenderer::InitializeSharedObjects"); | 2988 TRACE_EVENT0("cc", "GLRenderer::InitializeSharedObjects"); |
| 2990 | 2989 |
| 2991 // Create an FBO for doing offscreen rendering. | 2990 // Create an FBO for doing offscreen rendering. |
| 2992 gl_->GenFramebuffers(1, &offscreen_framebuffer_id_); | 2991 gl_->GenFramebuffers(1, &offscreen_framebuffer_id_); |
| 2993 | 2992 |
| 2994 shared_geometry_ = | 2993 shared_geometry_ = |
| 2995 make_scoped_ptr(new StaticGeometryBinding(gl_, QuadVertexRect())); | 2994 base::WrapUnique(new StaticGeometryBinding(gl_, QuadVertexRect())); |
| 2996 clipped_geometry_ = make_scoped_ptr(new DynamicGeometryBinding(gl_)); | 2995 clipped_geometry_ = base::WrapUnique(new DynamicGeometryBinding(gl_)); |
| 2997 } | 2996 } |
| 2998 | 2997 |
| 2999 void GLRenderer::PrepareGeometry(BoundGeometry binding) { | 2998 void GLRenderer::PrepareGeometry(BoundGeometry binding) { |
| 3000 if (binding == bound_geometry_) { | 2999 if (binding == bound_geometry_) { |
| 3001 return; | 3000 return; |
| 3002 } | 3001 } |
| 3003 | 3002 |
| 3004 switch (binding) { | 3003 switch (binding) { |
| 3005 case SHARED_BINDING: | 3004 case SHARED_BINDING: |
| 3006 shared_geometry_->PrepareForDraw(); | 3005 shared_geometry_->PrepareForDraw(); |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3540 | 3539 |
| 3541 bool GLRenderer::IsContextLost() { | 3540 bool GLRenderer::IsContextLost() { |
| 3542 return gl_->GetGraphicsResetStatusKHR() != GL_NO_ERROR; | 3541 return gl_->GetGraphicsResetStatusKHR() != GL_NO_ERROR; |
| 3543 } | 3542 } |
| 3544 | 3543 |
| 3545 void GLRenderer::ScheduleCALayers(DrawingFrame* frame) { | 3544 void GLRenderer::ScheduleCALayers(DrawingFrame* frame) { |
| 3546 for (const CALayerOverlay& ca_layer_overlay : frame->ca_layer_overlay_list) { | 3545 for (const CALayerOverlay& ca_layer_overlay : frame->ca_layer_overlay_list) { |
| 3547 unsigned texture_id = 0; | 3546 unsigned texture_id = 0; |
| 3548 if (ca_layer_overlay.contents_resource_id) { | 3547 if (ca_layer_overlay.contents_resource_id) { |
| 3549 pending_overlay_resources_.push_back( | 3548 pending_overlay_resources_.push_back( |
| 3550 make_scoped_ptr(new ResourceProvider::ScopedReadLockGL( | 3549 base::WrapUnique(new ResourceProvider::ScopedReadLockGL( |
| 3551 resource_provider_, ca_layer_overlay.contents_resource_id))); | 3550 resource_provider_, ca_layer_overlay.contents_resource_id))); |
| 3552 texture_id = pending_overlay_resources_.back()->texture_id(); | 3551 texture_id = pending_overlay_resources_.back()->texture_id(); |
| 3553 } | 3552 } |
| 3554 GLfloat contents_rect[4] = { | 3553 GLfloat contents_rect[4] = { |
| 3555 ca_layer_overlay.contents_rect.x(), ca_layer_overlay.contents_rect.y(), | 3554 ca_layer_overlay.contents_rect.x(), ca_layer_overlay.contents_rect.y(), |
| 3556 ca_layer_overlay.contents_rect.width(), | 3555 ca_layer_overlay.contents_rect.width(), |
| 3557 ca_layer_overlay.contents_rect.height(), | 3556 ca_layer_overlay.contents_rect.height(), |
| 3558 }; | 3557 }; |
| 3559 GLfloat bounds_rect[4] = { | 3558 GLfloat bounds_rect[4] = { |
| 3560 ca_layer_overlay.bounds_rect.x(), ca_layer_overlay.bounds_rect.y(), | 3559 ca_layer_overlay.bounds_rect.x(), ca_layer_overlay.bounds_rect.y(), |
| (...skipping 20 matching lines...) Expand all Loading... |
| 3581 return; | 3580 return; |
| 3582 | 3581 |
| 3583 OverlayCandidateList& overlays = frame->overlay_list; | 3582 OverlayCandidateList& overlays = frame->overlay_list; |
| 3584 for (const OverlayCandidate& overlay : overlays) { | 3583 for (const OverlayCandidate& overlay : overlays) { |
| 3585 unsigned texture_id = 0; | 3584 unsigned texture_id = 0; |
| 3586 if (overlay.use_output_surface_for_resource) { | 3585 if (overlay.use_output_surface_for_resource) { |
| 3587 texture_id = output_surface_->GetOverlayTextureId(); | 3586 texture_id = output_surface_->GetOverlayTextureId(); |
| 3588 DCHECK(texture_id || IsContextLost()); | 3587 DCHECK(texture_id || IsContextLost()); |
| 3589 } else { | 3588 } else { |
| 3590 pending_overlay_resources_.push_back( | 3589 pending_overlay_resources_.push_back( |
| 3591 make_scoped_ptr(new ResourceProvider::ScopedReadLockGL( | 3590 base::WrapUnique(new ResourceProvider::ScopedReadLockGL( |
| 3592 resource_provider_, overlay.resource_id))); | 3591 resource_provider_, overlay.resource_id))); |
| 3593 texture_id = pending_overlay_resources_.back()->texture_id(); | 3592 texture_id = pending_overlay_resources_.back()->texture_id(); |
| 3594 } | 3593 } |
| 3595 | 3594 |
| 3596 context_support_->ScheduleOverlayPlane( | 3595 context_support_->ScheduleOverlayPlane( |
| 3597 overlay.plane_z_order, overlay.transform, texture_id, | 3596 overlay.plane_z_order, overlay.transform, texture_id, |
| 3598 ToNearestRect(overlay.display_rect), overlay.uv_rect); | 3597 ToNearestRect(overlay.display_rect), overlay.uv_rect); |
| 3599 } | 3598 } |
| 3600 } | 3599 } |
| 3601 | 3600 |
| 3602 } // namespace cc | 3601 } // namespace cc |
| OLD | NEW |