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

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: Rebase to 165064 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
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_texture.h" 10 #include "cc/prioritized_texture.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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 } 62 }
64 63
65 size_t ResourceUpdateController::maxFullUpdatesPerTick( 64 size_t ResourceUpdateController::maxFullUpdatesPerTick(
66 ResourceProvider* resourceProvider) 65 ResourceProvider* resourceProvider)
67 { 66 {
68 double texturesPerSecond = resourceProvider->estimatedUploadsPerSecond(); 67 double texturesPerSecond = resourceProvider->estimatedUploadsPerSecond();
69 size_t texturesPerTick = floor(textureUpdateTickRate * texturesPerSecond); 68 size_t texturesPerTick = floor(textureUpdateTickRate * texturesPerSecond);
70 return texturesPerTick ? texturesPerTick : 1; 69 return texturesPerTick ? texturesPerTick : 1;
71 } 70 }
72 71
73 ResourceUpdateController::ResourceUpdateController(ResourceUpdateControllerClien t* client, Thread* thread, scoped_ptr<ResourceUpdateQueue> queue, ResourceProvid er* resourceProvider) 72 ResourceUpdateController::ResourceUpdateController(ResourceUpdateControllerClien t* client, Thread* thread, scoped_ptr<ResourceUpdateQueue> queue, ResourceProvid er* resourceProvider, bool hasImplThread)
74 : m_client(client) 73 : m_client(client)
74 , m_hasImplThread(hasImplThread)
75 , m_queue(queue.Pass()) 75 , m_queue(queue.Pass())
76 , m_resourceProvider(resourceProvider) 76 , m_resourceProvider(resourceProvider)
77 , m_textureUpdatesPerTick(maxFullUpdatesPerTick(resourceProvider)) 77 , m_textureUpdatesPerTick(maxFullUpdatesPerTick(resourceProvider))
78 , m_firstUpdateAttempt(true) 78 , m_firstUpdateAttempt(true)
79 , m_thread(thread) 79 , m_thread(thread)
80 , m_weakFactory(ALLOW_THIS_IN_INITIALIZER_LIST(this)) 80 , m_weakFactory(ALLOW_THIS_IN_INITIALIZER_LIST(this))
81 , m_taskPosted(false) 81 , m_taskPosted(false)
82 { 82 {
83 } 83 }
84 84
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 IntRect pictureRect = update.content_rect; 124 IntRect pictureRect = update.content_rect;
125 IntRect sourceRect = update.source_rect; 125 IntRect sourceRect = update.source_rect;
126 IntSize destOffset = update.dest_offset; 126 IntSize destOffset = update.dest_offset;
127 127
128 texture->acquireBackingTexture(m_resourceProvider); 128 texture->acquireBackingTexture(m_resourceProvider);
129 DCHECK(texture->haveBackingTexture()); 129 DCHECK(texture->haveBackingTexture());
130 130
131 DCHECK(m_resourceProvider->resourceType(texture->resourceId()) == 131 DCHECK(m_resourceProvider->resourceType(texture->resourceId()) ==
132 ResourceProvider::GLTexture); 132 ResourceProvider::GLTexture);
133 133
134 WebGraphicsContext3D* paintContext = Proxy::hasImplThread() ? 134 WebGraphicsContext3D* paintContext = m_hasImplThread ?
135 WebSharedGraphicsContext3D::compositorThreadContext() : 135 WebSharedGraphicsContext3D::compositorThreadContext() :
136 WebSharedGraphicsContext3D::mainThreadContext(); 136 WebSharedGraphicsContext3D::mainThreadContext();
137 GrContext* paintGrContext = Proxy::hasImplThread() ? 137 GrContext* paintGrContext = m_hasImplThread ?
138 WebSharedGraphicsContext3D::compositorThreadGrContext() : 138 WebSharedGraphicsContext3D::compositorThreadGrContext() :
139 WebSharedGraphicsContext3D::mainThreadGrContext(); 139 WebSharedGraphicsContext3D::mainThreadGrContext();
140 140
141 // Flush the context in which the backing texture is created so that it 141 // Flush the context in which the backing texture is created so that it
142 // is available in other shared contexts. It is important to do here 142 // is available in other shared contexts. It is important to do here
143 // because the backing texture is created in one context while it is 143 // because the backing texture is created in one context while it is
144 // being written to in another. 144 // being written to in another.
145 m_resourceProvider->flush(); 145 m_resourceProvider->flush();
146 ResourceProvider::ScopedWriteLockGL lock( 146 ResourceProvider::ScopedWriteLockGL lock(
147 m_resourceProvider, texture->resourceId()); 147 m_resourceProvider, texture->resourceId());
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 while (m_queue->fullUploadSize() && uploadCount < uploads) { 295 while (m_queue->fullUploadSize() && uploadCount < uploads) {
296 if (!(uploadCount % textureUploadFlushPeriod) && uploadCount) 296 if (!(uploadCount % textureUploadFlushPeriod) && uploadCount)
297 m_resourceProvider->shallowFlushIfSupported(); 297 m_resourceProvider->shallowFlushIfSupported();
298 updateTexture(m_queue->takeFirstFullUpload()); 298 updateTexture(m_queue->takeFirstFullUpload());
299 uploadCount++; 299 uploadCount++;
300 } 300 }
301 m_resourceProvider->shallowFlushIfSupported(); 301 m_resourceProvider->shallowFlushIfSupported();
302 } 302 }
303 303
304 } // namespace cc 304 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698