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

Side by Side Diff: cc/resources/resource_provider.cc

Issue 732423002: Update from chromium https://crrev.com/304586 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 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/resources/recording_source.h ('k') | cc/resources/resource_provider_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 "cc/resources/resource_provider.h" 5 #include "cc/resources/resource_provider.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/containers/hash_tables.h" 10 #include "base/containers/hash_tables.h"
11 #include "base/debug/trace_event.h" 11 #include "base/debug/trace_event.h"
12 #include "base/metrics/histogram.h"
12 #include "base/stl_util.h" 13 #include "base/stl_util.h"
13 #include "base/strings/string_split.h" 14 #include "base/strings/string_split.h"
14 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
15 #include "cc/base/util.h" 16 #include "cc/base/util.h"
16 #include "cc/output/gl_renderer.h" // For the GLC() macro. 17 #include "cc/output/gl_renderer.h" // For the GLC() macro.
17 #include "cc/resources/platform_color.h" 18 #include "cc/resources/platform_color.h"
18 #include "cc/resources/returned_resource.h" 19 #include "cc/resources/returned_resource.h"
19 #include "cc/resources/shared_bitmap_manager.h" 20 #include "cc/resources/shared_bitmap_manager.h"
20 #include "cc/resources/texture_uploader.h" 21 #include "cc/resources/texture_uploader.h"
21 #include "cc/resources/transferable_resource.h" 22 #include "cc/resources/transferable_resource.h"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 next_id_index_ = 0; 192 next_id_index_ = 0;
192 } 193 }
193 194
194 return ids_[next_id_index_++]; 195 return ids_[next_id_index_++];
195 } 196 }
196 197
197 private: 198 private:
198 DISALLOW_COPY_AND_ASSIGN(BufferIdAllocator); 199 DISALLOW_COPY_AND_ASSIGN(BufferIdAllocator);
199 }; 200 };
200 201
201 // Generic fence implementation for query objects. Fence has passed when query 202 // Query object based fence implementation used to detect completion of copy
202 // result is available. 203 // texture operations. Fence has passed when query result is available.
203 class QueryFence : public ResourceProvider::Fence { 204 class CopyTextureFence : public ResourceProvider::Fence {
204 public: 205 public:
205 QueryFence(gpu::gles2::GLES2Interface* gl, unsigned query_id) 206 CopyTextureFence(gpu::gles2::GLES2Interface* gl, unsigned query_id)
206 : gl_(gl), query_id_(query_id) {} 207 : gl_(gl), query_id_(query_id) {}
207 208
208 // Overridden from ResourceProvider::Fence: 209 // Overridden from ResourceProvider::Fence:
209 void Set() override {} 210 void Set() override {}
210 bool HasPassed() override { 211 bool HasPassed() override {
211 unsigned available = 1; 212 unsigned available = 1;
212 gl_->GetQueryObjectuivEXT( 213 gl_->GetQueryObjectuivEXT(
213 query_id_, GL_QUERY_RESULT_AVAILABLE_EXT, &available); 214 query_id_, GL_QUERY_RESULT_AVAILABLE_EXT, &available);
214 return !!available; 215 if (!available)
216 return false;
217
218 ProcessResult();
219 return true;
215 } 220 }
216 void Wait() override { 221 void Wait() override {
217 unsigned result = 0; 222 // ProcessResult() will wait for result to become available.
218 gl_->GetQueryObjectuivEXT(query_id_, GL_QUERY_RESULT_EXT, &result); 223 ProcessResult();
219 } 224 }
220 225
221 private: 226 private:
222 ~QueryFence() override {} 227 ~CopyTextureFence() override {}
228
229 void ProcessResult() {
230 unsigned time_elapsed_us = 0;
231 gl_->GetQueryObjectuivEXT(query_id_, GL_QUERY_RESULT_EXT, &time_elapsed_us);
232 UMA_HISTOGRAM_CUSTOM_COUNTS("Renderer4.CopyTextureLatency", time_elapsed_us,
233 0, 256000, 50);
234 }
223 235
224 gpu::gles2::GLES2Interface* gl_; 236 gpu::gles2::GLES2Interface* gl_;
225 unsigned query_id_; 237 unsigned query_id_;
226 238
227 DISALLOW_COPY_AND_ASSIGN(QueryFence); 239 DISALLOW_COPY_AND_ASSIGN(CopyTextureFence);
228 }; 240 };
229 241
230 } // namespace 242 } // namespace
231 243
232 ResourceProvider::Resource::Resource() 244 ResourceProvider::Resource::Resource()
233 : child_id(0), 245 : child_id(0),
234 gl_id(0), 246 gl_id(0),
235 gl_pixel_buffer_id(0), 247 gl_pixel_buffer_id(0),
236 gl_upload_query_id(0), 248 gl_upload_query_id(0),
237 gl_read_lock_query_id(0), 249 gl_read_lock_query_id(0),
(...skipping 1832 matching lines...) Expand 10 before | Expand all | Expand 10 after
2070 source_resource->gl_id, 2082 source_resource->gl_id,
2071 dest_resource->gl_id, 2083 dest_resource->gl_id,
2072 0, 2084 0,
2073 GLInternalFormat(dest_resource->format), 2085 GLInternalFormat(dest_resource->format),
2074 GLDataType(dest_resource->format)); 2086 GLDataType(dest_resource->format));
2075 if (source_resource->gl_read_lock_query_id) { 2087 if (source_resource->gl_read_lock_query_id) {
2076 // End query and create a read lock fence that will prevent access to 2088 // End query and create a read lock fence that will prevent access to
2077 // source resource until CopyTextureCHROMIUM command has completed. 2089 // source resource until CopyTextureCHROMIUM command has completed.
2078 gl->EndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM); 2090 gl->EndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM);
2079 source_resource->read_lock_fence = make_scoped_refptr( 2091 source_resource->read_lock_fence = make_scoped_refptr(
2080 new QueryFence(gl, source_resource->gl_read_lock_query_id)); 2092 new CopyTextureFence(gl, source_resource->gl_read_lock_query_id));
2081 } else { 2093 } else {
2082 // Create a SynchronousFence when CHROMIUM_sync_query extension is missing. 2094 // Create a SynchronousFence when CHROMIUM_sync_query extension is missing.
2083 // Try to use one synchronous fence for as many CopyResource operations as 2095 // Try to use one synchronous fence for as many CopyResource operations as
2084 // possible as that reduce the number of times we have to synchronize with 2096 // possible as that reduce the number of times we have to synchronize with
2085 // the GL. 2097 // the GL.
2086 if (!synchronous_fence_.get() || synchronous_fence_->has_synchronized()) 2098 if (!synchronous_fence_.get() || synchronous_fence_->has_synchronized())
2087 synchronous_fence_ = make_scoped_refptr(new SynchronousFence(gl)); 2099 synchronous_fence_ = make_scoped_refptr(new SynchronousFence(gl));
2088 source_resource->read_lock_fence = synchronous_fence_; 2100 source_resource->read_lock_fence = synchronous_fence_;
2089 source_resource->read_lock_fence->Set(); 2101 source_resource->read_lock_fence->Set();
2090 } 2102 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2124 ContextProvider* context_provider = output_surface_->context_provider(); 2136 ContextProvider* context_provider = output_surface_->context_provider();
2125 return context_provider ? context_provider->ContextGL() : NULL; 2137 return context_provider ? context_provider->ContextGL() : NULL;
2126 } 2138 }
2127 2139
2128 class GrContext* ResourceProvider::GrContext() const { 2140 class GrContext* ResourceProvider::GrContext() const {
2129 ContextProvider* context_provider = output_surface_->context_provider(); 2141 ContextProvider* context_provider = output_surface_->context_provider();
2130 return context_provider ? context_provider->GrContext() : NULL; 2142 return context_provider ? context_provider->GrContext() : NULL;
2131 } 2143 }
2132 2144
2133 } // namespace cc 2145 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/recording_source.h ('k') | cc/resources/resource_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698