OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/delegating_renderer.h" | 5 #include "cc/output/delegating_renderer.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 // Software compositing. | 66 // Software compositing. |
67 return true; | 67 return true; |
68 } | 68 } |
69 | 69 |
70 if (!context3d->makeContextCurrent()) | 70 if (!context3d->makeContextCurrent()) |
71 return false; | 71 return false; |
72 | 72 |
73 context3d->setContextLostCallback(this); | 73 context3d->setContextLostCallback(this); |
74 context3d->pushGroupMarkerEXT("CompositorContext"); | 74 context3d->pushGroupMarkerEXT("CompositorContext"); |
75 | 75 |
76 std::string extensionsString = | 76 std::string extensions_string = |
77 UTF16ToASCII(context3d->getString(GL_EXTENSIONS)); | 77 UTF16ToASCII(context3d->getString(GL_EXTENSIONS)); |
78 | 78 |
79 std::vector<std::string> extensions; | 79 std::vector<std::string> extensions; |
80 base::SplitString(extensionsString, ' ', &extensions); | 80 base::SplitString(extensions_string, ' ', &extensions); |
81 | 81 |
82 // TODO(danakj): We need non-GPU-specific paths for these things. This | 82 // TODO(danakj): We need non-GPU-specific paths for these things. This |
83 // renderer shouldn't need to use context3d extensions directly. | 83 // renderer shouldn't need to use context3d extensions directly. |
84 bool hasReadBGRA = true; | 84 bool has_read_bgra = true; |
85 bool hasSetVisibility = true; | 85 bool has_set_visibility = true; |
86 bool hasIOSurface = true; | 86 bool has_io_surface = true; |
87 bool hasARBTextureRect = true; | 87 bool has_arb_texture_rect = true; |
88 bool hasGpuMemoryManager = true; | 88 bool has_gpu_memory_manager = true; |
89 bool hasEGLImage = true; | 89 bool has_egl_image = true; |
90 for (size_t i = 0; i < extensions.size(); ++i) { | 90 for (size_t i = 0; i < extensions.size(); ++i) { |
91 if (extensions[i] == "GL_EXT_read_format_bgra") | 91 if (extensions[i] == "GL_EXT_read_format_bgra") |
92 hasReadBGRA = true; | 92 has_read_bgra = true; |
93 else if (extensions[i] == "GL_CHROMIUM_set_visibility") | 93 else if (extensions[i] == "GL_CHROMIUM_set_visibility") |
94 hasSetVisibility = true; | 94 has_set_visibility = true; |
95 else if (extensions[i] == "GL_CHROMIUM_iosurface") | 95 else if (extensions[i] == "GL_CHROMIUM_iosurface") |
96 hasIOSurface = true; | 96 has_io_surface = true; |
97 else if (extensions[i] == "GL_ARB_texture_rectangle") | 97 else if (extensions[i] == "GL_ARB_texture_rectangle") |
98 hasARBTextureRect = true; | 98 has_arb_texture_rect = true; |
99 else if (extensions[i] == "GL_CHROMIUM_gpu_memory_manager") | 99 else if (extensions[i] == "GL_CHROMIUM_gpu_memory_manager") |
100 hasGpuMemoryManager = true; | 100 has_gpu_memory_manager = true; |
101 else if (extensions[i] == "GL_OES_EGL_image_external") | 101 else if (extensions[i] == "GL_OES_EGL_image_external") |
102 hasEGLImage = true; | 102 has_egl_image = true; |
103 } | 103 } |
104 | 104 |
105 if (hasIOSurface) | 105 if (has_io_surface) |
106 DCHECK(hasARBTextureRect); | 106 DCHECK(has_arb_texture_rect); |
107 | 107 |
108 capabilities_.using_accelerated_painting = | 108 capabilities_.using_accelerated_painting = |
109 Settings().accelerate_painting && | 109 Settings().accelerate_painting && |
110 capabilities_.best_texture_format == GL_BGRA_EXT && | 110 capabilities_.best_texture_format == GL_BGRA_EXT && |
111 hasReadBGRA; | 111 has_read_bgra; |
112 | 112 |
113 // TODO(piman): loop visibility to GPU process? | 113 // TODO(piman): loop visibility to GPU process? |
114 capabilities_.using_set_visibility = hasSetVisibility; | 114 capabilities_.using_set_visibility = has_set_visibility; |
115 | 115 |
116 // TODO(danakj): Support GpuMemoryManager. | 116 // TODO(danakj): Support GpuMemoryManager. |
117 capabilities_.using_gpu_memory_manager = false; | 117 capabilities_.using_gpu_memory_manager = false; |
118 | 118 |
119 capabilities_.using_egl_image = hasEGLImage; | 119 capabilities_.using_egl_image = has_egl_image; |
120 | 120 |
121 return true; | 121 return true; |
122 } | 122 } |
123 | 123 |
124 DelegatingRenderer::~DelegatingRenderer() { | 124 DelegatingRenderer::~DelegatingRenderer() { |
125 WebGraphicsContext3D* context3d = resource_provider_->GraphicsContext3D(); | 125 WebGraphicsContext3D* context3d = resource_provider_->GraphicsContext3D(); |
126 if (context3d) | 126 if (context3d) |
127 context3d->setContextLostCallback(NULL); | 127 context3d->setContextLostCallback(NULL); |
128 } | 128 } |
129 | 129 |
130 const RendererCapabilities& DelegatingRenderer::Capabilities() const { | 130 const RendererCapabilities& DelegatingRenderer::Capabilities() const { |
131 return capabilities_; | 131 return capabilities_; |
132 } | 132 } |
133 | 133 |
134 static ResourceProvider::ResourceId AppendToArray( | 134 static ResourceProvider::ResourceId AppendToArray( |
135 ResourceProvider::ResourceIdArray* array, | 135 ResourceProvider::ResourceIdArray* array, |
136 ResourceProvider::ResourceId id) { | 136 ResourceProvider::ResourceId id) { |
137 array->push_back(id); | 137 array->push_back(id); |
138 return id; | 138 return id; |
139 } | 139 } |
140 | 140 |
141 void DelegatingRenderer::DrawFrame( | 141 void DelegatingRenderer::DrawFrame( |
142 RenderPassList& render_passes_in_draw_order) { | 142 RenderPassList& render_passes_in_draw_order) { |
143 TRACE_EVENT0("cc", "DelegatingRenderer::drawFrame"); | 143 TRACE_EVENT0("cc", "DelegatingRenderer::DrawFrame"); |
144 | 144 |
145 CompositorFrame out_frame; | 145 CompositorFrame out_frame; |
146 out_frame.metadata = client_->MakeCompositorFrameMetadata(); | 146 out_frame.metadata = client_->MakeCompositorFrameMetadata(); |
147 | 147 |
148 out_frame.delegated_frame_data = make_scoped_ptr(new DelegatedFrameData); | 148 out_frame.delegated_frame_data = make_scoped_ptr(new DelegatedFrameData); |
149 | 149 |
150 // Collect all resource ids in the render passes into a ResourceIdArray. | 150 // Collect all resource ids in the render passes into a ResourceIdArray. |
151 ResourceProvider::ResourceIdArray resources; | 151 ResourceProvider::ResourceIdArray resources; |
152 DrawQuad::ResourceIteratorCallback append_to_array = | 152 DrawQuad::ResourceIteratorCallback append_to_array = |
153 base::Bind(&AppendToArray, &resources); | 153 base::Bind(&AppendToArray, &resources); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 | 190 |
191 void DelegatingRenderer::SetVisible(bool visible) { | 191 void DelegatingRenderer::SetVisible(bool visible) { |
192 visible_ = visible; | 192 visible_ = visible; |
193 } | 193 } |
194 | 194 |
195 void DelegatingRenderer::onContextLost() { | 195 void DelegatingRenderer::onContextLost() { |
196 client_->DidLoseOutputSurface(); | 196 client_->DidLoseOutputSurface(); |
197 } | 197 } |
198 | 198 |
199 } // namespace cc | 199 } // namespace cc |
OLD | NEW |