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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "cc/texture_uploader.h" | 7 #include "cc/texture_uploader.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <vector> | 10 #include <vector> |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 // How many previous uploads to use when predicting future throughput. | 25 // How many previous uploads to use when predicting future throughput. |
26 static const size_t uploadHistorySizeMax = 1000; | 26 static const size_t uploadHistorySizeMax = 1000; |
27 static const size_t uploadHistorySizeInitial = 100; | 27 static const size_t uploadHistorySizeInitial = 100; |
28 | 28 |
29 // Global estimated number of textures per second to maintain estimates across | 29 // Global estimated number of textures per second to maintain estimates across |
30 // subsequent instances of TextureUploader. | 30 // subsequent instances of TextureUploader. |
31 // More than one thread will not access this variable, so we do not need to sync
hronize access. | 31 // More than one thread will not access this variable, so we do not need to sync
hronize access. |
32 static const double defaultEstimatedTexturesPerSecond = 48.0 * 60.0; | 32 static const double defaultEstimatedTexturesPerSecond = 48.0 * 60.0; |
33 | 33 |
| 34 // Flush interval when performing texture uploads. |
| 35 const int textureUploadFlushPeriod = 4; |
| 36 |
34 } // anonymous namespace | 37 } // anonymous namespace |
35 | 38 |
36 namespace cc { | 39 namespace cc { |
37 | 40 |
38 TextureUploader::Query::Query(WebKit::WebGraphicsContext3D* context) | 41 TextureUploader::Query::Query(WebKit::WebGraphicsContext3D* context) |
39 : m_context(context) | 42 : m_context(context) |
40 , m_queryId(0) | 43 , m_queryId(0) |
41 , m_value(0) | 44 , m_value(0) |
42 , m_hasValue(false) | 45 , m_hasValue(false) |
43 , m_isNonBlocking(false) | 46 , m_isNonBlocking(false) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 { | 85 { |
83 m_isNonBlocking = true; | 86 m_isNonBlocking = true; |
84 } | 87 } |
85 | 88 |
86 bool TextureUploader::Query::isNonBlocking() | 89 bool TextureUploader::Query::isNonBlocking() |
87 { | 90 { |
88 return m_isNonBlocking; | 91 return m_isNonBlocking; |
89 } | 92 } |
90 | 93 |
91 TextureUploader::TextureUploader( | 94 TextureUploader::TextureUploader( |
92 WebKit::WebGraphicsContext3D* context, bool useMapTexSubImage) | 95 WebKit::WebGraphicsContext3D* context, |
| 96 bool useMapTexSubImage, |
| 97 bool useShallowFlush) |
93 : m_context(context) | 98 : m_context(context) |
94 , m_numBlockingTextureUploads(0) | 99 , m_numBlockingTextureUploads(0) |
95 , m_useMapTexSubImage(useMapTexSubImage) | 100 , m_useMapTexSubImage(useMapTexSubImage) |
96 , m_subImageSize(0) | 101 , m_subImageSize(0) |
| 102 , m_useShallowFlush(useShallowFlush) |
| 103 , m_numTextureUploadsSinceLastFlush(0) |
97 { | 104 { |
98 for (size_t i = uploadHistorySizeInitial; i > 0; i--) | 105 for (size_t i = uploadHistorySizeInitial; i > 0; i--) |
99 m_texturesPerSecondHistory.insert(defaultEstimatedTexturesPerSecond); | 106 m_texturesPerSecondHistory.insert(defaultEstimatedTexturesPerSecond); |
100 } | 107 } |
101 | 108 |
102 TextureUploader::~TextureUploader() | 109 TextureUploader::~TextureUploader() |
103 { | 110 { |
104 } | 111 } |
105 | 112 |
106 size_t TextureUploader::numBlockingUploads() | 113 size_t TextureUploader::numBlockingUploads() |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 if (m_useMapTexSubImage) { | 173 if (m_useMapTexSubImage) { |
167 uploadWithMapTexSubImage( | 174 uploadWithMapTexSubImage( |
168 image, image_rect, source_rect, dest_offset, format); | 175 image, image_rect, source_rect, dest_offset, format); |
169 } else { | 176 } else { |
170 uploadWithTexSubImage( | 177 uploadWithTexSubImage( |
171 image, image_rect, source_rect, dest_offset, format); | 178 image, image_rect, source_rect, dest_offset, format); |
172 } | 179 } |
173 | 180 |
174 if (isFullUpload) | 181 if (isFullUpload) |
175 endQuery(); | 182 endQuery(); |
| 183 |
| 184 m_numTextureUploadsSinceLastFlush++; |
| 185 if (m_numTextureUploadsSinceLastFlush >= textureUploadFlushPeriod) |
| 186 flush(); |
| 187 } |
| 188 |
| 189 void TextureUploader::flush() { |
| 190 if (!m_numTextureUploadsSinceLastFlush) |
| 191 return; |
| 192 |
| 193 if (m_useShallowFlush) |
| 194 m_context->shallowFlushCHROMIUM(); |
| 195 |
| 196 m_numTextureUploadsSinceLastFlush = 0; |
176 } | 197 } |
177 | 198 |
178 void TextureUploader::uploadWithTexSubImage(const uint8* image, | 199 void TextureUploader::uploadWithTexSubImage(const uint8* image, |
179 const gfx::Rect& image_rect, | 200 const gfx::Rect& image_rect, |
180 const gfx::Rect& source_rect, | 201 const gfx::Rect& source_rect, |
181 const gfx::Vector2d& dest_offset, | 202 const gfx::Vector2d& dest_offset, |
182 GLenum format) | 203 GLenum format) |
183 { | 204 { |
184 // Instrumentation to debug issue 156107 | 205 // Instrumentation to debug issue 156107 |
185 int source_rect_x = source_rect.x(); | 206 int source_rect_x = source_rect.x(); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 m_texturesPerSecondHistory.erase(m_texturesPerSecondHistory.begin())
; | 351 m_texturesPerSecondHistory.erase(m_texturesPerSecondHistory.begin())
; |
331 m_texturesPerSecondHistory.erase(--m_texturesPerSecondHistory.end())
; | 352 m_texturesPerSecondHistory.erase(--m_texturesPerSecondHistory.end())
; |
332 } | 353 } |
333 m_texturesPerSecondHistory.insert(texturesPerSecond); | 354 m_texturesPerSecondHistory.insert(texturesPerSecond); |
334 | 355 |
335 m_availableQueries.append(m_pendingQueries.takeFirst()); | 356 m_availableQueries.append(m_pendingQueries.takeFirst()); |
336 } | 357 } |
337 } | 358 } |
338 | 359 |
339 } | 360 } |
OLD | NEW |