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

Side by Side Diff: cc/texture_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 Dana's code review suggestions Created 8 years, 2 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
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/texture_update_controller.h" 7 #include "cc/texture_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 "third_party/khronos/GLES2/gl2.h" 13 #include "third_party/khronos/GLES2/gl2.h"
15 #include "third_party/skia/include/gpu/SkGpuDevice.h" 14 #include "third_party/skia/include/gpu/SkGpuDevice.h"
16 #include <limits> 15 #include <limits>
17 #include <public/WebGraphicsContext3D.h> 16 #include <public/WebGraphicsContext3D.h>
18 #include <public/WebSharedGraphicsContext3D.h> 17 #include <public/WebSharedGraphicsContext3D.h>
19 #include <wtf/CurrentTime.h> 18 #include <wtf/CurrentTime.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 TextureUpdateController::maxFullUpdatesPerTick( 64 size_t TextureUpdateController::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 TextureUpdateController::TextureUpdateController(TextureUpdateControllerClient* client, Thread* thread, scoped_ptr<TextureUpdateQueue> queue, ResourceProvider* resourceProvider) 72 TextureUpdateController::TextureUpdateController(TextureUpdateControllerClient* client, Thread* thread, scoped_ptr<TextureUpdateQueue> queue, ResourceProvider* resourceProvider, bool hasImplThread)
74 : m_client(client) 73 : m_client(client)
74 , m_hasImplThread(hasImplThread)
75 , m_timer(new Timer(thread, this)) 75 , m_timer(new Timer(thread, this))
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 { 80 {
81 } 81 }
82 82
83 TextureUpdateController::~TextureUpdateController() 83 TextureUpdateController::~TextureUpdateController()
84 { 84 {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 IntRect pictureRect = update.content_rect; 119 IntRect pictureRect = update.content_rect;
120 IntRect sourceRect = update.source_rect; 120 IntRect sourceRect = update.source_rect;
121 IntSize destOffset = update.dest_offset; 121 IntSize destOffset = update.dest_offset;
122 122
123 texture->acquireBackingTexture(m_resourceProvider); 123 texture->acquireBackingTexture(m_resourceProvider);
124 DCHECK(texture->haveBackingTexture()); 124 DCHECK(texture->haveBackingTexture());
125 125
126 DCHECK(m_resourceProvider->resourceType(texture->resourceId()) == 126 DCHECK(m_resourceProvider->resourceType(texture->resourceId()) ==
127 ResourceProvider::GLTexture); 127 ResourceProvider::GLTexture);
128 128
129 WebGraphicsContext3D* paintContext = Proxy::hasImplThread() ? 129 WebGraphicsContext3D* paintContext = m_hasImplThread ?
130 WebSharedGraphicsContext3D::compositorThreadContext() : 130 WebSharedGraphicsContext3D::compositorThreadContext() :
131 WebSharedGraphicsContext3D::mainThreadContext(); 131 WebSharedGraphicsContext3D::mainThreadContext();
132 GrContext* paintGrContext = Proxy::hasImplThread() ? 132 GrContext* paintGrContext = m_hasImplThread ?
133 WebSharedGraphicsContext3D::compositorThreadGrContext() : 133 WebSharedGraphicsContext3D::compositorThreadGrContext() :
134 WebSharedGraphicsContext3D::mainThreadGrContext(); 134 WebSharedGraphicsContext3D::mainThreadGrContext();
135 135
136 // Flush the context in which the backing texture is created so that it 136 // Flush the context in which the backing texture is created so that it
137 // is available in other shared contexts. It is important to do here 137 // is available in other shared contexts. It is important to do here
138 // because the backing texture is created in one context while it is 138 // because the backing texture is created in one context while it is
139 // being written to in another. 139 // being written to in another.
140 m_resourceProvider->flush(); 140 m_resourceProvider->flush();
141 ResourceProvider::ScopedWriteLockGL lock( 141 ResourceProvider::ScopedWriteLockGL lock(
142 m_resourceProvider, texture->resourceId()); 142 m_resourceProvider, texture->resourceId());
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 while (m_queue->fullUploadSize() && uploadCount < uploads) { 283 while (m_queue->fullUploadSize() && uploadCount < uploads) {
284 if (!(uploadCount % textureUploadFlushPeriod) && uploadCount) 284 if (!(uploadCount % textureUploadFlushPeriod) && uploadCount)
285 m_resourceProvider->shallowFlushIfSupported(); 285 m_resourceProvider->shallowFlushIfSupported();
286 updateTexture(m_queue->takeFirstFullUpload()); 286 updateTexture(m_queue->takeFirstFullUpload());
287 uploadCount++; 287 uploadCount++;
288 } 288 }
289 m_resourceProvider->shallowFlushIfSupported(); 289 m_resourceProvider->shallowFlushIfSupported();
290 } 290 }
291 291
292 } // namespace cc 292 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698