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 "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 1111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1122 resource_provider_->LazyAllocate(resource_); | 1122 resource_provider_->LazyAllocate(resource_); |
1123 } | 1123 } |
1124 | 1124 |
1125 ResourceProvider::ScopedWriteLockGr::~ScopedWriteLockGr() { | 1125 ResourceProvider::ScopedWriteLockGr::~ScopedWriteLockGr() { |
1126 DCHECK(thread_checker_.CalledOnValidThread()); | 1126 DCHECK(thread_checker_.CalledOnValidThread()); |
1127 DCHECK(resource_->locked_for_write); | 1127 DCHECK(resource_->locked_for_write); |
1128 resource_provider_->UnlockForWrite(resource_); | 1128 resource_provider_->UnlockForWrite(resource_); |
1129 } | 1129 } |
1130 | 1130 |
1131 void ResourceProvider::ScopedWriteLockGr::InitSkSurface( | 1131 void ResourceProvider::ScopedWriteLockGr::InitSkSurface( |
1132 bool use_worker_context, | |
1133 bool use_distance_field_text, | 1132 bool use_distance_field_text, |
1134 bool can_use_lcd_text, | 1133 bool can_use_lcd_text, |
1135 int msaa_sample_count) { | 1134 int msaa_sample_count) { |
1136 DCHECK(resource_->locked_for_write); | 1135 DCHECK(resource_->locked_for_write); |
1137 | 1136 |
1138 GrBackendTextureDesc desc; | 1137 GrBackendTextureDesc desc; |
1139 desc.fFlags = kRenderTarget_GrBackendTextureFlag; | 1138 desc.fFlags = kRenderTarget_GrBackendTextureFlag; |
1140 desc.fWidth = resource_->size.width(); | 1139 desc.fWidth = resource_->size.width(); |
1141 desc.fHeight = resource_->size.height(); | 1140 desc.fHeight = resource_->size.height(); |
1142 desc.fConfig = ToGrPixelConfig(resource_->format); | 1141 desc.fConfig = ToGrPixelConfig(resource_->format); |
1143 desc.fOrigin = kTopLeft_GrSurfaceOrigin; | 1142 desc.fOrigin = kTopLeft_GrSurfaceOrigin; |
1144 desc.fTextureHandle = resource_->gl_id; | 1143 desc.fTextureHandle = resource_->gl_id; |
1145 desc.fSampleCnt = msaa_sample_count; | 1144 desc.fSampleCnt = msaa_sample_count; |
1146 | 1145 |
| 1146 bool use_worker_context = true; |
1147 class GrContext* gr_context = | 1147 class GrContext* gr_context = |
1148 resource_provider_->GrContext(use_worker_context); | 1148 resource_provider_->GrContext(use_worker_context); |
1149 skia::RefPtr<GrTexture> gr_texture = | 1149 skia::RefPtr<GrTexture> gr_texture = |
1150 skia::AdoptRef(gr_context->wrapBackendTexture(desc)); | 1150 skia::AdoptRef(gr_context->wrapBackendTexture(desc)); |
1151 if (gr_texture) { | 1151 if (gr_texture) { |
1152 uint32_t flags = use_distance_field_text | 1152 uint32_t flags = use_distance_field_text |
1153 ? SkSurfaceProps::kUseDistanceFieldFonts_Flag | 1153 ? SkSurfaceProps::kUseDistanceFieldFonts_Flag |
1154 : 0; | 1154 : 0; |
1155 // Use unknown pixel geometry to disable LCD text. | 1155 // Use unknown pixel geometry to disable LCD text. |
1156 SkSurfaceProps surface_props(flags, kUnknown_SkPixelGeometry); | 1156 SkSurfaceProps surface_props(flags, kUnknown_SkPixelGeometry); |
(...skipping 1006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2163 } | 2163 } |
2164 | 2164 |
2165 class GrContext* ResourceProvider::GrContext(bool worker_context) const { | 2165 class GrContext* ResourceProvider::GrContext(bool worker_context) const { |
2166 ContextProvider* context_provider = | 2166 ContextProvider* context_provider = |
2167 worker_context ? output_surface_->worker_context_provider() | 2167 worker_context ? output_surface_->worker_context_provider() |
2168 : output_surface_->context_provider(); | 2168 : output_surface_->context_provider(); |
2169 return context_provider ? context_provider->GrContext() : NULL; | 2169 return context_provider ? context_provider->GrContext() : NULL; |
2170 } | 2170 } |
2171 | 2171 |
2172 } // namespace cc | 2172 } // namespace cc |
OLD | NEW |