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