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 <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/debug/trace_event.h" | 13 #include "base/debug/trace_event.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/strings/string_split.h" | 15 #include "base/strings/string_split.h" |
16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 17 #include "base/strings/stringprintf.h" |
17 #include "build/build_config.h" | 18 #include "build/build_config.h" |
18 #include "cc/base/math_util.h" | 19 #include "cc/base/math_util.h" |
19 #include "cc/layers/video_layer_impl.h" | 20 #include "cc/layers/video_layer_impl.h" |
20 #include "cc/output/compositor_frame.h" | 21 #include "cc/output/compositor_frame.h" |
21 #include "cc/output/compositor_frame_metadata.h" | 22 #include "cc/output/compositor_frame_metadata.h" |
22 #include "cc/output/context_provider.h" | 23 #include "cc/output/context_provider.h" |
23 #include "cc/output/copy_output_request.h" | 24 #include "cc/output/copy_output_request.h" |
24 #include "cc/output/copy_output_result.h" | 25 #include "cc/output/copy_output_result.h" |
25 #include "cc/output/geometry_binding.h" | 26 #include "cc/output/geometry_binding.h" |
26 #include "cc/output/gl_frame_data.h" | 27 #include "cc/output/gl_frame_data.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 offscreen_framebuffer_id_(0), | 142 offscreen_framebuffer_id_(0), |
142 shared_geometry_quad_(gfx::RectF(-0.5f, -0.5f, 1.0f, 1.0f)), | 143 shared_geometry_quad_(gfx::RectF(-0.5f, -0.5f, 1.0f, 1.0f)), |
143 context_(output_surface->context3d()), | 144 context_(output_surface->context3d()), |
144 is_backbuffer_discarded_(false), | 145 is_backbuffer_discarded_(false), |
145 discard_backbuffer_when_not_visible_(false), | 146 discard_backbuffer_when_not_visible_(false), |
146 is_using_bind_uniform_(false), | 147 is_using_bind_uniform_(false), |
147 visible_(true), | 148 visible_(true), |
148 is_scissor_enabled_(false), | 149 is_scissor_enabled_(false), |
149 highp_threshold_min_(highp_threshold_min), | 150 highp_threshold_min_(highp_threshold_min), |
150 highp_threshold_cache_(0), | 151 highp_threshold_cache_(0), |
| 152 offscreen_context_labelled_(false), |
151 on_demand_tile_raster_resource_id_(0), | 153 on_demand_tile_raster_resource_id_(0), |
152 weak_factory_(this) { | 154 weak_factory_(this) { |
153 DCHECK(context_); | 155 DCHECK(context_); |
154 } | 156 } |
155 | 157 |
156 bool GLRenderer::Initialize() { | 158 bool GLRenderer::Initialize() { |
157 if (!context_->makeContextCurrent()) | 159 if (!context_->makeContextCurrent()) |
158 return false; | 160 return false; |
159 | 161 |
160 context_->pushGroupMarkerEXT(Settings().compositor_name.c_str()); | 162 std::string unique_context_name = base::StringPrintf( |
| 163 "%s-%p", |
| 164 Settings().compositor_name.c_str(), |
| 165 context_); |
| 166 context_->pushGroupMarkerEXT(unique_context_name.c_str()); |
161 | 167 |
162 std::string extensions_string = | 168 std::string extensions_string = |
163 UTF16ToASCII(context_->getString(GL_EXTENSIONS)); | 169 UTF16ToASCII(context_->getString(GL_EXTENSIONS)); |
164 std::vector<std::string> extensions_list; | 170 std::vector<std::string> extensions_list; |
165 base::SplitString(extensions_string, ' ', &extensions_list); | 171 base::SplitString(extensions_string, ' ', &extensions_list); |
166 std::set<std::string> extensions(extensions_list.begin(), | 172 std::set<std::string> extensions(extensions_list.begin(), |
167 extensions_list.end()); | 173 extensions_list.end()); |
168 | 174 |
169 capabilities_.using_partial_swap = | 175 capabilities_.using_partial_swap = |
170 Settings().partial_swap_enabled && | 176 Settings().partial_swap_enabled && |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 source_texture_resource->id()); | 469 source_texture_resource->id()); |
464 | 470 |
465 // Flush the compositor context to ensure that textures there are available | 471 // Flush the compositor context to ensure that textures there are available |
466 // in the shared context. Do this after locking/creating the compositor | 472 // in the shared context. Do this after locking/creating the compositor |
467 // texture. | 473 // texture. |
468 renderer->resource_provider()->Flush(); | 474 renderer->resource_provider()->Flush(); |
469 | 475 |
470 // Make sure skia uses the correct GL context. | 476 // Make sure skia uses the correct GL context. |
471 offscreen_contexts->Context3d()->makeContextCurrent(); | 477 offscreen_contexts->Context3d()->makeContextCurrent(); |
472 | 478 |
| 479 // Lazily label this context. |
| 480 renderer->LazyLabelOffscreenContext(); |
| 481 |
473 SkBitmap source = | 482 SkBitmap source = |
474 RenderSurfaceFilters::Apply(filters, | 483 RenderSurfaceFilters::Apply(filters, |
475 lock.texture_id(), | 484 lock.texture_id(), |
476 source_texture_resource->size(), | 485 source_texture_resource->size(), |
477 offscreen_contexts->GrContext()); | 486 offscreen_contexts->GrContext()); |
478 | 487 |
479 // Flush skia context so that all the rendered stuff appears on the | 488 // Flush skia context so that all the rendered stuff appears on the |
480 // texture. | 489 // texture. |
481 offscreen_contexts->GrContext()->flush(); | 490 offscreen_contexts->GrContext()->flush(); |
482 | 491 |
(...skipping 21 matching lines...) Expand all Loading... |
504 source_texture_resource->id()); | 513 source_texture_resource->id()); |
505 | 514 |
506 // Flush the compositor context to ensure that textures there are available | 515 // Flush the compositor context to ensure that textures there are available |
507 // in the shared context. Do this after locking/creating the compositor | 516 // in the shared context. Do this after locking/creating the compositor |
508 // texture. | 517 // texture. |
509 renderer->resource_provider()->Flush(); | 518 renderer->resource_provider()->Flush(); |
510 | 519 |
511 // Make sure skia uses the correct GL context. | 520 // Make sure skia uses the correct GL context. |
512 offscreen_contexts->Context3d()->makeContextCurrent(); | 521 offscreen_contexts->Context3d()->makeContextCurrent(); |
513 | 522 |
| 523 // Lazily label this context. |
| 524 renderer->LazyLabelOffscreenContext(); |
| 525 |
514 // Wrap the source texture in a Ganesh platform texture. | 526 // Wrap the source texture in a Ganesh platform texture. |
515 GrBackendTextureDesc backend_texture_description; | 527 GrBackendTextureDesc backend_texture_description; |
516 backend_texture_description.fWidth = source_texture_resource->size().width(); | 528 backend_texture_description.fWidth = source_texture_resource->size().width(); |
517 backend_texture_description.fHeight = | 529 backend_texture_description.fHeight = |
518 source_texture_resource->size().height(); | 530 source_texture_resource->size().height(); |
519 backend_texture_description.fConfig = kSkia8888_GrPixelConfig; | 531 backend_texture_description.fConfig = kSkia8888_GrPixelConfig; |
520 backend_texture_description.fTextureHandle = lock.texture_id(); | 532 backend_texture_description.fTextureHandle = lock.texture_id(); |
521 backend_texture_description.fOrigin = kBottomLeft_GrSurfaceOrigin; | 533 backend_texture_description.fOrigin = kBottomLeft_GrSurfaceOrigin; |
522 skia::RefPtr<GrTexture> texture = | 534 skia::RefPtr<GrTexture> texture = |
523 skia::AdoptRef(offscreen_contexts->GrContext()->wrapBackendTexture( | 535 skia::AdoptRef(offscreen_contexts->GrContext()->wrapBackendTexture( |
(...skipping 2509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3033 bool GLRenderer::CanUseSkiaGPUBackend() const { | 3045 bool GLRenderer::CanUseSkiaGPUBackend() const { |
3034 // The Skia GPU backend requires a stencil buffer. See ReinitializeGrCanvas | 3046 // The Skia GPU backend requires a stencil buffer. See ReinitializeGrCanvas |
3035 // implementation. | 3047 // implementation. |
3036 return gr_context_ && context_->getContextAttributes().stencil; | 3048 return gr_context_ && context_->getContextAttributes().stencil; |
3037 } | 3049 } |
3038 | 3050 |
3039 bool GLRenderer::IsContextLost() { | 3051 bool GLRenderer::IsContextLost() { |
3040 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR); | 3052 return (context_->getGraphicsResetStatusARB() != GL_NO_ERROR); |
3041 } | 3053 } |
3042 | 3054 |
| 3055 void GLRenderer::LazyLabelOffscreenContext() { |
| 3056 if (offscreen_context_labelled_) |
| 3057 return; |
| 3058 offscreen_context_labelled_ = true; |
| 3059 std::string unique_context_name = base::StringPrintf( |
| 3060 "%s-Offscreen-%p", |
| 3061 Settings().compositor_name.c_str(), |
| 3062 context_); |
| 3063 resource_provider()->offscreen_context_provider()->Context3d()-> |
| 3064 pushGroupMarkerEXT(unique_context_name.c_str()); |
| 3065 } |
| 3066 |
| 3067 |
3043 } // namespace cc | 3068 } // namespace cc |
OLD | NEW |