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

Side by Side Diff: cc/resource_update_controller.cc

Issue 11232051: Remove static thread pointers from CC (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Apply code review comments Created 8 years, 1 month 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
« no previous file with comments | « cc/resource_update_controller.h ('k') | cc/resource_update_controller_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 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 "config.h" 5 #include "config.h"
6 6
7 #include "cc/resource_update_controller.h" 7 #include "cc/resource_update_controller.h"
8 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "cc/prioritized_resource.h" 10 #include "cc/prioritized_resource.h"
11 #include "cc/proxy.h"
12 #include "cc/resource_provider.h" 11 #include "cc/resource_provider.h"
13 #include "cc/texture_copier.h" 12 #include "cc/texture_copier.h"
14 #include "cc/thread.h" 13 #include "cc/thread.h"
15 #include "third_party/khronos/GLES2/gl2.h" 14 #include "third_party/khronos/GLES2/gl2.h"
16 #include "third_party/skia/include/gpu/SkGpuDevice.h" 15 #include "third_party/skia/include/gpu/SkGpuDevice.h"
17 #include <limits> 16 #include <limits>
18 #include <public/WebGraphicsContext3D.h> 17 #include <public/WebGraphicsContext3D.h>
19 #include <public/WebSharedGraphicsContext3D.h> 18 #include <public/WebSharedGraphicsContext3D.h>
20 19
21 using WebKit::WebGraphicsContext3D; 20 using WebKit::WebGraphicsContext3D;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 } 63 }
65 64
66 size_t ResourceUpdateController::maxFullUpdatesPerTick( 65 size_t ResourceUpdateController::maxFullUpdatesPerTick(
67 ResourceProvider* resourceProvider) 66 ResourceProvider* resourceProvider)
68 { 67 {
69 double texturesPerSecond = resourceProvider->estimatedUploadsPerSecond(); 68 double texturesPerSecond = resourceProvider->estimatedUploadsPerSecond();
70 size_t texturesPerTick = floor(textureUpdateTickRate * texturesPerSecond); 69 size_t texturesPerTick = floor(textureUpdateTickRate * texturesPerSecond);
71 return texturesPerTick ? texturesPerTick : 1; 70 return texturesPerTick ? texturesPerTick : 1;
72 } 71 }
73 72
74 ResourceUpdateController::ResourceUpdateController(ResourceUpdateControllerClien t* client, Thread* thread, scoped_ptr<ResourceUpdateQueue> queue, ResourceProvid er* resourceProvider) 73 ResourceUpdateController::ResourceUpdateController(ResourceUpdateControllerClien t* client, Thread* thread, scoped_ptr<ResourceUpdateQueue> queue, ResourceProvid er* resourceProvider, bool hasImplThread)
75 : m_client(client) 74 : m_client(client)
75 , m_hasImplThread(hasImplThread)
76 , m_queue(queue.Pass()) 76 , m_queue(queue.Pass())
77 , m_resourceProvider(resourceProvider) 77 , m_resourceProvider(resourceProvider)
78 , m_textureUpdatesPerTick(maxFullUpdatesPerTick(resourceProvider)) 78 , m_textureUpdatesPerTick(maxFullUpdatesPerTick(resourceProvider))
79 , m_firstUpdateAttempt(true) 79 , m_firstUpdateAttempt(true)
80 , m_thread(thread) 80 , m_thread(thread)
81 , m_weakFactory(ALLOW_THIS_IN_INITIALIZER_LIST(this)) 81 , m_weakFactory(ALLOW_THIS_IN_INITIALIZER_LIST(this))
82 , m_taskPosted(false) 82 , m_taskPosted(false)
83 { 83 {
84 } 84 }
85 85
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 gfx::Rect pictureRect = update.content_rect; 126 gfx::Rect pictureRect = update.content_rect;
127 gfx::Rect sourceRect = update.source_rect; 127 gfx::Rect sourceRect = update.source_rect;
128 gfx::Vector2d destOffset = update.dest_offset; 128 gfx::Vector2d destOffset = update.dest_offset;
129 129
130 texture->acquireBackingTexture(m_resourceProvider); 130 texture->acquireBackingTexture(m_resourceProvider);
131 DCHECK(texture->haveBackingTexture()); 131 DCHECK(texture->haveBackingTexture());
132 132
133 DCHECK(m_resourceProvider->resourceType(texture->resourceId()) == 133 DCHECK(m_resourceProvider->resourceType(texture->resourceId()) ==
134 ResourceProvider::GLTexture); 134 ResourceProvider::GLTexture);
135 135
136 WebGraphicsContext3D* paintContext = Proxy::hasImplThread() ? 136 WebGraphicsContext3D* paintContext = m_hasImplThread ?
137 WebSharedGraphicsContext3D::compositorThreadContext() : 137 WebSharedGraphicsContext3D::compositorThreadContext() :
138 WebSharedGraphicsContext3D::mainThreadContext(); 138 WebSharedGraphicsContext3D::mainThreadContext();
139 GrContext* paintGrContext = Proxy::hasImplThread() ? 139 GrContext* paintGrContext = m_hasImplThread ?
140 WebSharedGraphicsContext3D::compositorThreadGrContext() : 140 WebSharedGraphicsContext3D::compositorThreadGrContext() :
141 WebSharedGraphicsContext3D::mainThreadGrContext(); 141 WebSharedGraphicsContext3D::mainThreadGrContext();
142 142
143 // Flush the context in which the backing texture is created so that it 143 // Flush the context in which the backing texture is created so that it
144 // is available in other shared contexts. It is important to do here 144 // is available in other shared contexts. It is important to do here
145 // because the backing texture is created in one context while it is 145 // because the backing texture is created in one context while it is
146 // being written to in another. 146 // being written to in another.
147 m_resourceProvider->flush(); 147 m_resourceProvider->flush();
148 ResourceProvider::ScopedWriteLockGL lock( 148 ResourceProvider::ScopedWriteLockGL lock(
149 m_resourceProvider, texture->resourceId()); 149 m_resourceProvider, texture->resourceId());
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 if (!uploads) 288 if (!uploads)
289 return; 289 return;
290 290
291 while (m_queue->fullUploadSize() && uploads--) 291 while (m_queue->fullUploadSize() && uploads--)
292 updateTexture(m_queue->takeFirstFullUpload()); 292 updateTexture(m_queue->takeFirstFullUpload());
293 293
294 m_resourceProvider->flushUploads(); 294 m_resourceProvider->flushUploads();
295 } 295 }
296 296
297 } // namespace cc 297 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resource_update_controller.h ('k') | cc/resource_update_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698