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

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

Issue 935333002: Update from https://crrev.com/316786 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « cc/resources/resource_provider.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"
(...skipping 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after
1080 gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer( 1080 gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer(
1081 size_, ToGpuMemoryBufferFormat(format_), gfx::GpuMemoryBuffer::MAP); 1081 size_, ToGpuMemoryBufferFormat(format_), gfx::GpuMemoryBuffer::MAP);
1082 gpu_memory_buffer_ = gpu_memory_buffer.release(); 1082 gpu_memory_buffer_ = gpu_memory_buffer.release();
1083 } 1083 }
1084 1084
1085 return gpu_memory_buffer_; 1085 return gpu_memory_buffer_;
1086 } 1086 }
1087 1087
1088 ResourceProvider::ScopedWriteLockGr::ScopedWriteLockGr( 1088 ResourceProvider::ScopedWriteLockGr::ScopedWriteLockGr(
1089 ResourceProvider* resource_provider, 1089 ResourceProvider* resource_provider,
1090 ResourceProvider::ResourceId resource_id, 1090 ResourceProvider::ResourceId resource_id)
1091 : resource_provider_(resource_provider),
1092 resource_(resource_provider->LockForWrite(resource_id)) {
1093 DCHECK(thread_checker_.CalledOnValidThread());
1094 resource_provider_->LazyAllocate(resource_);
1095 }
1096
1097 ResourceProvider::ScopedWriteLockGr::~ScopedWriteLockGr() {
1098 DCHECK(thread_checker_.CalledOnValidThread());
1099 DCHECK(resource_->locked_for_write);
1100 resource_provider_->UnlockForWrite(resource_);
1101 }
1102
1103 void ResourceProvider::ScopedWriteLockGr::InitSkSurface(
1104 bool use_worker_context,
1091 bool use_distance_field_text, 1105 bool use_distance_field_text,
1092 bool can_use_lcd_text, 1106 bool can_use_lcd_text,
1093 int msaa_sample_count) 1107 int msaa_sample_count) {
1094 : resource_provider_(resource_provider),
1095 resource_(resource_provider->LockForWrite(resource_id)) {
1096 // Create the sk_surface.
1097 DCHECK(thread_checker_.CalledOnValidThread());
1098 DCHECK(resource_->locked_for_write); 1108 DCHECK(resource_->locked_for_write);
1099 1109
1100 resource_provider_->LazyAllocate(resource_);
1101
1102 GrBackendTextureDesc desc; 1110 GrBackendTextureDesc desc;
1103 desc.fFlags = kRenderTarget_GrBackendTextureFlag; 1111 desc.fFlags = kRenderTarget_GrBackendTextureFlag;
1104 desc.fWidth = resource_->size.width(); 1112 desc.fWidth = resource_->size.width();
1105 desc.fHeight = resource_->size.height(); 1113 desc.fHeight = resource_->size.height();
1106 desc.fConfig = ToGrPixelConfig(resource_->format); 1114 desc.fConfig = ToGrPixelConfig(resource_->format);
1107 desc.fOrigin = kTopLeft_GrSurfaceOrigin; 1115 desc.fOrigin = kTopLeft_GrSurfaceOrigin;
1108 desc.fTextureHandle = resource_->gl_id; 1116 desc.fTextureHandle = resource_->gl_id;
1109 desc.fSampleCnt = msaa_sample_count; 1117 desc.fSampleCnt = msaa_sample_count;
1110 1118
1111 class GrContext* gr_context = resource_provider_->GrContext(); 1119 class GrContext* gr_context =
1120 resource_provider_->GrContext(use_worker_context);
1112 skia::RefPtr<GrTexture> gr_texture = 1121 skia::RefPtr<GrTexture> gr_texture =
1113 skia::AdoptRef(gr_context->wrapBackendTexture(desc)); 1122 skia::AdoptRef(gr_context->wrapBackendTexture(desc));
1114 if (gr_texture) { 1123 if (gr_texture) {
1115 uint32_t flags = use_distance_field_text 1124 uint32_t flags = use_distance_field_text
1116 ? SkSurfaceProps::kUseDistanceFieldFonts_Flag 1125 ? SkSurfaceProps::kUseDistanceFieldFonts_Flag
1117 : 0; 1126 : 0;
1118 // Use unknown pixel geometry to disable LCD text. 1127 // Use unknown pixel geometry to disable LCD text.
1119 SkSurfaceProps surface_props(flags, kUnknown_SkPixelGeometry); 1128 SkSurfaceProps surface_props(flags, kUnknown_SkPixelGeometry);
1120 if (can_use_lcd_text) { 1129 if (can_use_lcd_text) {
1121 // LegacyFontHost will get LCD text and skia figures out what type to use. 1130 // LegacyFontHost will get LCD text and skia figures out what type to use.
1122 surface_props = 1131 surface_props =
1123 SkSurfaceProps(flags, SkSurfaceProps::kLegacyFontHost_InitType); 1132 SkSurfaceProps(flags, SkSurfaceProps::kLegacyFontHost_InitType);
1124 } 1133 }
1125 sk_surface_ = skia::AdoptRef(SkSurface::NewRenderTargetDirect( 1134 sk_surface_ = skia::AdoptRef(SkSurface::NewRenderTargetDirect(
1126 gr_texture->asRenderTarget(), &surface_props)); 1135 gr_texture->asRenderTarget(), &surface_props));
1136 return;
1127 } 1137 }
1138 sk_surface_.clear();
1128 } 1139 }
1129 1140
1130 ResourceProvider::ScopedWriteLockGr::~ScopedWriteLockGr() { 1141 void ResourceProvider::ScopedWriteLockGr::ReleaseSkSurface() {
1131 DCHECK(thread_checker_.CalledOnValidThread()); 1142 sk_surface_.clear();
1132 resource_provider_->UnlockForWrite(resource_);
1133 } 1143 }
1134 1144
1135 ResourceProvider::SynchronousFence::SynchronousFence( 1145 ResourceProvider::SynchronousFence::SynchronousFence(
1136 gpu::gles2::GLES2Interface* gl) 1146 gpu::gles2::GLES2Interface* gl)
1137 : gl_(gl), has_synchronized_(true) { 1147 : gl_(gl), has_synchronized_(true) {
1138 } 1148 }
1139 1149
1140 ResourceProvider::SynchronousFence::~SynchronousFence() { 1150 ResourceProvider::SynchronousFence::~SynchronousFence() {
1141 } 1151 }
1142 1152
(...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after
2128 GLint active_unit = 0; 2138 GLint active_unit = 0;
2129 gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit); 2139 gl->GetIntegerv(GL_ACTIVE_TEXTURE, &active_unit);
2130 return active_unit; 2140 return active_unit;
2131 } 2141 }
2132 2142
2133 GLES2Interface* ResourceProvider::ContextGL() const { 2143 GLES2Interface* ResourceProvider::ContextGL() const {
2134 ContextProvider* context_provider = output_surface_->context_provider(); 2144 ContextProvider* context_provider = output_surface_->context_provider();
2135 return context_provider ? context_provider->ContextGL() : NULL; 2145 return context_provider ? context_provider->ContextGL() : NULL;
2136 } 2146 }
2137 2147
2138 class GrContext* ResourceProvider::GrContext() const { 2148 class GrContext* ResourceProvider::GrContext(bool worker_context) const {
2139 ContextProvider* context_provider = output_surface_->context_provider(); 2149 ContextProvider* context_provider =
2150 worker_context ? output_surface_->worker_context_provider()
2151 : output_surface_->context_provider();
2140 return context_provider ? context_provider->GrContext() : NULL; 2152 return context_provider ? context_provider->GrContext() : NULL;
2141 } 2153 }
2142 2154
2143 } // namespace cc 2155 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/resource_provider.h ('k') | cc/resources/resource_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698