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

Side by Side Diff: cc/output/gl_renderer.cc

Issue 23454014: cc: Drop ContextProvider references on the impl thread before quitting (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: callbackcontrolcenter: rebase Created 7 years, 3 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
« no previous file with comments | « cc/output/gl_renderer.h ('k') | cc/output/gl_renderer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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>
(...skipping 15 matching lines...) Expand all
26 #include "cc/output/gl_frame_data.h" 26 #include "cc/output/gl_frame_data.h"
27 #include "cc/output/output_surface.h" 27 #include "cc/output/output_surface.h"
28 #include "cc/output/render_surface_filters.h" 28 #include "cc/output/render_surface_filters.h"
29 #include "cc/quads/picture_draw_quad.h" 29 #include "cc/quads/picture_draw_quad.h"
30 #include "cc/quads/render_pass.h" 30 #include "cc/quads/render_pass.h"
31 #include "cc/quads/stream_video_draw_quad.h" 31 #include "cc/quads/stream_video_draw_quad.h"
32 #include "cc/quads/texture_draw_quad.h" 32 #include "cc/quads/texture_draw_quad.h"
33 #include "cc/resources/layer_quad.h" 33 #include "cc/resources/layer_quad.h"
34 #include "cc/resources/scoped_resource.h" 34 #include "cc/resources/scoped_resource.h"
35 #include "cc/resources/sync_point_helper.h" 35 #include "cc/resources/sync_point_helper.h"
36 #include "cc/resources/texture_mailbox_deleter.h"
36 #include "cc/trees/damage_tracker.h" 37 #include "cc/trees/damage_tracker.h"
37 #include "cc/trees/proxy.h" 38 #include "cc/trees/proxy.h"
38 #include "cc/trees/single_thread_proxy.h" 39 #include "cc/trees/single_thread_proxy.h"
39 #include "gpu/GLES2/gl2extchromium.h" 40 #include "gpu/GLES2/gl2extchromium.h"
40 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" 41 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
41 #include "third_party/khronos/GLES2/gl2.h" 42 #include "third_party/khronos/GLES2/gl2.h"
42 #include "third_party/khronos/GLES2/gl2ext.h" 43 #include "third_party/khronos/GLES2/gl2ext.h"
43 #include "third_party/skia/include/core/SkBitmap.h" 44 #include "third_party/skia/include/core/SkBitmap.h"
44 #include "third_party/skia/include/core/SkColor.h" 45 #include "third_party/skia/include/core/SkColor.h"
45 #include "third_party/skia/include/core/SkColorFilter.h" 46 #include "third_party/skia/include/core/SkColorFilter.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 PendingAsyncReadPixels() : buffer(0) {} 120 PendingAsyncReadPixels() : buffer(0) {}
120 121
121 scoped_ptr<CopyOutputRequest> copy_request; 122 scoped_ptr<CopyOutputRequest> copy_request;
122 base::CancelableClosure finished_read_pixels_callback; 123 base::CancelableClosure finished_read_pixels_callback;
123 unsigned buffer; 124 unsigned buffer;
124 125
125 private: 126 private:
126 DISALLOW_COPY_AND_ASSIGN(PendingAsyncReadPixels); 127 DISALLOW_COPY_AND_ASSIGN(PendingAsyncReadPixels);
127 }; 128 };
128 129
129 scoped_ptr<GLRenderer> GLRenderer::Create(RendererClient* client, 130 scoped_ptr<GLRenderer> GLRenderer::Create(
130 const LayerTreeSettings* settings, 131 RendererClient* client,
131 OutputSurface* output_surface, 132 const LayerTreeSettings* settings,
132 ResourceProvider* resource_provider, 133 OutputSurface* output_surface,
133 int highp_threshold_min, 134 ResourceProvider* resource_provider,
134 bool use_skia_gpu_backend) { 135 TextureMailboxDeleter* texture_mailbox_deleter,
136 int highp_threshold_min,
137 bool use_skia_gpu_backend) {
135 scoped_ptr<GLRenderer> renderer(new GLRenderer(client, 138 scoped_ptr<GLRenderer> renderer(new GLRenderer(client,
136 settings, 139 settings,
137 output_surface, 140 output_surface,
138 resource_provider, 141 resource_provider,
142 texture_mailbox_deleter,
139 highp_threshold_min)); 143 highp_threshold_min));
140 if (!renderer->Initialize()) 144 if (!renderer->Initialize())
141 return scoped_ptr<GLRenderer>(); 145 return scoped_ptr<GLRenderer>();
142 if (use_skia_gpu_backend) { 146 if (use_skia_gpu_backend) {
143 renderer->InitializeGrContext(); 147 renderer->InitializeGrContext();
144 DCHECK(renderer->CanUseSkiaGPUBackend()) 148 DCHECK(renderer->CanUseSkiaGPUBackend())
145 << "Requested Skia GPU backend, but can't use it."; 149 << "Requested Skia GPU backend, but can't use it.";
146 } 150 }
147 151
148 return renderer.Pass(); 152 return renderer.Pass();
149 } 153 }
150 154
151 GLRenderer::GLRenderer(RendererClient* client, 155 GLRenderer::GLRenderer(RendererClient* client,
152 const LayerTreeSettings* settings, 156 const LayerTreeSettings* settings,
153 OutputSurface* output_surface, 157 OutputSurface* output_surface,
154 ResourceProvider* resource_provider, 158 ResourceProvider* resource_provider,
159 TextureMailboxDeleter* texture_mailbox_deleter,
155 int highp_threshold_min) 160 int highp_threshold_min)
156 : DirectRenderer(client, settings, output_surface, resource_provider), 161 : DirectRenderer(client, settings, output_surface, resource_provider),
157 offscreen_framebuffer_id_(0), 162 offscreen_framebuffer_id_(0),
158 shared_geometry_quad_(gfx::RectF(-0.5f, -0.5f, 1.0f, 1.0f)), 163 shared_geometry_quad_(gfx::RectF(-0.5f, -0.5f, 1.0f, 1.0f)),
159 context_(output_surface->context_provider()->Context3d()), 164 context_(output_surface->context_provider()->Context3d()),
165 texture_mailbox_deleter_(texture_mailbox_deleter),
160 is_backbuffer_discarded_(false), 166 is_backbuffer_discarded_(false),
161 discard_backbuffer_when_not_visible_(false), 167 discard_backbuffer_when_not_visible_(false),
162 is_using_bind_uniform_(false), 168 is_using_bind_uniform_(false),
163 visible_(true), 169 visible_(true),
164 is_scissor_enabled_(false), 170 is_scissor_enabled_(false),
165 stencil_shadow_(false), 171 stencil_shadow_(false),
166 blend_shadow_(false), 172 blend_shadow_(false),
167 highp_threshold_min_(highp_threshold_min), 173 highp_threshold_min_(highp_threshold_min),
168 highp_threshold_cache_(0), 174 highp_threshold_cache_(0),
169 offscreen_context_labelled_(false), 175 offscreen_context_labelled_(false),
(...skipping 2006 matching lines...) Expand 10 before | Expand all | Expand 10 after
2176 pending_async_read_pixels_.insert(pending_async_read_pixels_.begin(), 2182 pending_async_read_pixels_.insert(pending_async_read_pixels_.begin(),
2177 pending_read.Pass()); 2183 pending_read.Pass());
2178 2184
2179 // This is a syncronous call since the callback is null. 2185 // This is a syncronous call since the callback is null.
2180 gfx::Rect window_rect = MoveFromDrawToWindowSpace(rect); 2186 gfx::Rect window_rect = MoveFromDrawToWindowSpace(rect);
2181 DoGetFramebufferPixels(static_cast<uint8*>(pixels), 2187 DoGetFramebufferPixels(static_cast<uint8*>(pixels),
2182 window_rect, 2188 window_rect,
2183 AsyncGetFramebufferPixelsCleanupCallback()); 2189 AsyncGetFramebufferPixelsCleanupCallback());
2184 } 2190 }
2185 2191
2186 static void DeleteTextureReleaseCallbackOnImplThread(
2187 const scoped_refptr<ContextProvider>& context_provider,
2188 unsigned texture_id,
2189 unsigned sync_point,
2190 bool lost_resource) {
2191 if (sync_point)
2192 context_provider->Context3d()->waitSyncPoint(sync_point);
2193 context_provider->Context3d()->deleteTexture(texture_id);
2194 }
2195
2196 static void DeleteTextureReleaseCallback(
2197 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
2198 const scoped_refptr<ContextProvider>& context_provider,
2199 unsigned texture_id,
2200 unsigned sync_point,
2201 bool lost_resource) {
2202 task_runner->PostTask(
2203 FROM_HERE,
2204 base::Bind(&DeleteTextureReleaseCallbackOnImplThread,
2205 context_provider,
2206 texture_id,
2207 sync_point,
2208 lost_resource));
2209 }
2210
2211 void GLRenderer::GetFramebufferPixelsAsync( 2192 void GLRenderer::GetFramebufferPixelsAsync(
2212 gfx::Rect rect, scoped_ptr<CopyOutputRequest> request) { 2193 gfx::Rect rect, scoped_ptr<CopyOutputRequest> request) {
2213 DCHECK(!request->IsEmpty()); 2194 DCHECK(!request->IsEmpty());
2214 if (request->IsEmpty()) 2195 if (request->IsEmpty())
2215 return; 2196 return;
2216 if (rect.IsEmpty()) 2197 if (rect.IsEmpty())
2217 return; 2198 return;
2218 2199
2219 DCHECK(gfx::Rect(current_surface_size_).Contains(rect)) << 2200 DCHECK(gfx::Rect(current_surface_size_).Contains(rect)) <<
2220 "current_surface_size_: " << current_surface_size_.ToString() << 2201 "current_surface_size_: " << current_surface_size_.ToString() <<
(...skipping 23 matching lines...) Expand all
2244 return; 2225 return;
2245 } 2226 }
2246 2227
2247 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, texture_id)); 2228 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, texture_id));
2248 GLC(context_, context_->produceTextureCHROMIUM( 2229 GLC(context_, context_->produceTextureCHROMIUM(
2249 GL_TEXTURE_2D, mailbox.name)); 2230 GL_TEXTURE_2D, mailbox.name));
2250 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, 0)); 2231 GLC(context_, context_->bindTexture(GL_TEXTURE_2D, 0));
2251 sync_point = context_->insertSyncPoint(); 2232 sync_point = context_->insertSyncPoint();
2252 scoped_ptr<TextureMailbox> texture_mailbox = make_scoped_ptr( 2233 scoped_ptr<TextureMailbox> texture_mailbox = make_scoped_ptr(
2253 new TextureMailbox(mailbox, 2234 new TextureMailbox(mailbox,
2254 base::Bind(&DeleteTextureReleaseCallback, 2235 texture_mailbox_deleter_->GetReleaseCallback(
2255 base::MessageLoopProxy::current(), 2236 output_surface_->context_provider(), texture_id),
2256 output_surface_->context_provider(),
2257 texture_id),
2258 GL_TEXTURE_2D, 2237 GL_TEXTURE_2D,
2259 sync_point)); 2238 sync_point));
2260 request->SendTextureResult(window_rect.size(), texture_mailbox.Pass()); 2239 request->SendTextureResult(window_rect.size(), texture_mailbox.Pass());
2261 return; 2240 return;
2262 } 2241 }
2263 2242
2264 DCHECK(request->force_bitmap_result()); 2243 DCHECK(request->force_bitmap_result());
2265 2244
2266 scoped_ptr<SkBitmap> bitmap(new SkBitmap); 2245 scoped_ptr<SkBitmap> bitmap(new SkBitmap);
2267 bitmap->setConfig(SkBitmap::kARGB_8888_Config, 2246 bitmap->setConfig(SkBitmap::kARGB_8888_Config,
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after
3161 return; 3140 return;
3162 offscreen_context_labelled_ = true; 3141 offscreen_context_labelled_ = true;
3163 std::string unique_context_name = base::StringPrintf( 3142 std::string unique_context_name = base::StringPrintf(
3164 "%s-Offscreen-%p", settings_->compositor_name.c_str(), context_); 3143 "%s-Offscreen-%p", settings_->compositor_name.c_str(), context_);
3165 offscreen_context_provider->Context3d() 3144 offscreen_context_provider->Context3d()
3166 ->pushGroupMarkerEXT(unique_context_name.c_str()); 3145 ->pushGroupMarkerEXT(unique_context_name.c_str());
3167 } 3146 }
3168 3147
3169 3148
3170 } // namespace cc 3149 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/gl_renderer.h ('k') | cc/output/gl_renderer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698