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

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

Issue 689463003: cc: Move FallbackFence implementation from GLRenderer to ResourceProvider. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@one-copy-throttling
Patch Set: rebase 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/resource_provider.h ('k') | cc/trees/layer_tree_host_impl.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"
(...skipping 1112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1123 skia::AdoptRef(gr_context->wrapBackendTexture(desc)); 1123 skia::AdoptRef(gr_context->wrapBackendTexture(desc));
1124 SkSurface::TextRenderMode text_render_mode = 1124 SkSurface::TextRenderMode text_render_mode =
1125 use_distance_field_text ? SkSurface::kDistanceField_TextRenderMode 1125 use_distance_field_text ? SkSurface::kDistanceField_TextRenderMode
1126 : SkSurface::kStandard_TextRenderMode; 1126 : SkSurface::kStandard_TextRenderMode;
1127 resource_->sk_surface = skia::AdoptRef(SkSurface::NewRenderTargetDirect( 1127 resource_->sk_surface = skia::AdoptRef(SkSurface::NewRenderTargetDirect(
1128 gr_texture->asRenderTarget(), text_render_mode)); 1128 gr_texture->asRenderTarget(), text_render_mode));
1129 } 1129 }
1130 return resource_->sk_surface.get(); 1130 return resource_->sk_surface.get();
1131 } 1131 }
1132 1132
1133 ResourceProvider::SynchronousFence::SynchronousFence(
1134 gpu::gles2::GLES2Interface* gl)
1135 : gl_(gl), has_synchronized_(true) {
1136 }
1137
1138 ResourceProvider::SynchronousFence::~SynchronousFence() {
1139 }
1140
1141 void ResourceProvider::SynchronousFence::Set() {
1142 has_synchronized_ = false;
1143 }
1144
1145 bool ResourceProvider::SynchronousFence::HasPassed() {
1146 if (!has_synchronized_) {
1147 has_synchronized_ = true;
1148 Synchronize();
1149 }
1150 return true;
1151 }
1152
1153 void ResourceProvider::SynchronousFence::Wait() {
1154 HasPassed();
1155 }
1156
1157 void ResourceProvider::SynchronousFence::Synchronize() {
1158 TRACE_EVENT0("cc", "ResourceProvider::SynchronousFence::Synchronize");
1159 gl_->Finish();
1160 }
1161
1133 ResourceProvider::ResourceProvider( 1162 ResourceProvider::ResourceProvider(
1134 OutputSurface* output_surface, 1163 OutputSurface* output_surface,
1135 SharedBitmapManager* shared_bitmap_manager, 1164 SharedBitmapManager* shared_bitmap_manager,
1136 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, 1165 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
1137 BlockingTaskRunner* blocking_main_thread_task_runner, 1166 BlockingTaskRunner* blocking_main_thread_task_runner,
1138 int highp_threshold_min, 1167 int highp_threshold_min,
1139 bool use_rgba_4444_texture_format, 1168 bool use_rgba_4444_texture_format,
1140 size_t id_allocation_chunk_size) 1169 size_t id_allocation_chunk_size)
1141 : output_surface_(output_surface), 1170 : output_surface_(output_surface),
1142 shared_bitmap_manager_(shared_bitmap_manager), 1171 shared_bitmap_manager_(shared_bitmap_manager),
(...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after
2016 DCHECK_EQ(source_resource->type, dest_resource->type); 2045 DCHECK_EQ(source_resource->type, dest_resource->type);
2017 DCHECK_EQ(source_resource->format, dest_resource->format); 2046 DCHECK_EQ(source_resource->format, dest_resource->format);
2018 DCHECK(source_resource->size == dest_resource->size); 2047 DCHECK(source_resource->size == dest_resource->size);
2019 2048
2020 GLES2Interface* gl = ContextGL(); 2049 GLES2Interface* gl = ContextGL();
2021 DCHECK(gl); 2050 DCHECK(gl);
2022 if (source_resource->image_id && source_resource->dirty_image) { 2051 if (source_resource->image_id && source_resource->dirty_image) {
2023 gl->BindTexture(source_resource->target, source_resource->gl_id); 2052 gl->BindTexture(source_resource->target, source_resource->gl_id);
2024 BindImageForSampling(source_resource); 2053 BindImageForSampling(source_resource);
2025 } 2054 }
2026 DCHECK(use_sync_query_) << "CHROMIUM_sync_query extension missing"; 2055 if (use_sync_query_) {
2027 if (!source_resource->gl_read_lock_query_id) 2056 if (!source_resource->gl_read_lock_query_id)
2028 gl->GenQueriesEXT(1, &source_resource->gl_read_lock_query_id); 2057 gl->GenQueriesEXT(1, &source_resource->gl_read_lock_query_id);
2029 gl->BeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM, 2058 gl->BeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM,
2030 source_resource->gl_read_lock_query_id); 2059 source_resource->gl_read_lock_query_id);
2060 }
2031 DCHECK(!dest_resource->image_id); 2061 DCHECK(!dest_resource->image_id);
2032 dest_resource->allocated = true; 2062 dest_resource->allocated = true;
2033 gl->CopyTextureCHROMIUM(dest_resource->target, 2063 gl->CopyTextureCHROMIUM(dest_resource->target,
2034 source_resource->gl_id, 2064 source_resource->gl_id,
2035 dest_resource->gl_id, 2065 dest_resource->gl_id,
2036 0, 2066 0,
2037 GLInternalFormat(dest_resource->format), 2067 GLInternalFormat(dest_resource->format),
2038 GLDataType(dest_resource->format)); 2068 GLDataType(dest_resource->format));
2039 // End query and create a read lock fence that will prevent access to 2069 if (source_resource->gl_read_lock_query_id) {
2040 // source resource until CopyTextureCHROMIUM command has completed. 2070 // End query and create a read lock fence that will prevent access to
2041 gl->EndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM); 2071 // source resource until CopyTextureCHROMIUM command has completed.
2042 source_resource->read_lock_fence = make_scoped_refptr( 2072 gl->EndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM);
2043 new QueryFence(gl, source_resource->gl_read_lock_query_id)); 2073 source_resource->read_lock_fence = make_scoped_refptr(
2074 new QueryFence(gl, source_resource->gl_read_lock_query_id));
2075 } else {
2076 // Create a SynchronousFence when CHROMIUM_sync_query extension is missing.
2077 // Try to use one synchronous fence for as many CopyResource operations as
2078 // possible as that reduce the number of times we have to synchronize with
2079 // the GL.
2080 if (!synchronous_fence_.get() || synchronous_fence_->has_synchronized())
2081 synchronous_fence_ = make_scoped_refptr(new SynchronousFence(gl));
2082 source_resource->read_lock_fence = synchronous_fence_;
2083 source_resource->read_lock_fence->Set();
2084 }
2044 } 2085 }
2045 2086
2046 void ResourceProvider::WaitSyncPointIfNeeded(ResourceId id) { 2087 void ResourceProvider::WaitSyncPointIfNeeded(ResourceId id) {
2047 Resource* resource = GetResource(id); 2088 Resource* resource = GetResource(id);
2048 DCHECK_EQ(resource->exported_count, 0); 2089 DCHECK_EQ(resource->exported_count, 0);
2049 DCHECK(resource->allocated); 2090 DCHECK(resource->allocated);
2050 if (resource->type != GLTexture || resource->gl_id) 2091 if (resource->type != GLTexture || resource->gl_id)
2051 return; 2092 return;
2052 if (!resource->mailbox.sync_point()) 2093 if (!resource->mailbox.sync_point())
2053 return; 2094 return;
(...skipping 23 matching lines...) Expand all
2077 ContextProvider* context_provider = output_surface_->context_provider(); 2118 ContextProvider* context_provider = output_surface_->context_provider();
2078 return context_provider ? context_provider->ContextGL() : NULL; 2119 return context_provider ? context_provider->ContextGL() : NULL;
2079 } 2120 }
2080 2121
2081 class GrContext* ResourceProvider::GrContext() const { 2122 class GrContext* ResourceProvider::GrContext() const {
2082 ContextProvider* context_provider = output_surface_->context_provider(); 2123 ContextProvider* context_provider = output_surface_->context_provider();
2083 return context_provider ? context_provider->GrContext() : NULL; 2124 return context_provider ? context_provider->GrContext() : NULL;
2084 } 2125 }
2085 2126
2086 } // namespace cc 2127 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/resource_provider.h ('k') | cc/trees/layer_tree_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698