| 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 1081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1092 resource_(resource_provider->LockForWrite(resource_id)) { | 1092 resource_(resource_provider->LockForWrite(resource_id)) { |
| 1093 } | 1093 } |
| 1094 | 1094 |
| 1095 ResourceProvider::ScopedWriteLockGr::~ScopedWriteLockGr() { | 1095 ResourceProvider::ScopedWriteLockGr::~ScopedWriteLockGr() { |
| 1096 DCHECK(thread_checker_.CalledOnValidThread()); | 1096 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1097 resource_provider_->UnlockForWrite(resource_); | 1097 resource_provider_->UnlockForWrite(resource_); |
| 1098 } | 1098 } |
| 1099 | 1099 |
| 1100 SkSurface* ResourceProvider::ScopedWriteLockGr::GetSkSurface( | 1100 SkSurface* ResourceProvider::ScopedWriteLockGr::GetSkSurface( |
| 1101 bool use_distance_field_text, | 1101 bool use_distance_field_text, |
| 1102 bool can_use_lcd_text) { | 1102 bool can_use_lcd_text, |
| 1103 int msaa_sample_count) { |
| 1103 DCHECK(thread_checker_.CalledOnValidThread()); | 1104 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1104 DCHECK(resource_->locked_for_write); | 1105 DCHECK(resource_->locked_for_write); |
| 1105 | 1106 |
| 1106 bool create_surface = | 1107 bool create_surface = |
| 1107 !resource_->sk_surface.get() || | 1108 !resource_->sk_surface.get() || |
| 1108 !SurfaceHasMatchingProperties(use_distance_field_text, can_use_lcd_text); | 1109 !SurfaceHasMatchingProperties(use_distance_field_text, can_use_lcd_text); |
| 1109 if (create_surface) { | 1110 if (create_surface) { |
| 1110 resource_provider_->LazyAllocate(resource_); | 1111 resource_provider_->LazyAllocate(resource_); |
| 1111 | 1112 |
| 1112 GrBackendTextureDesc desc; | 1113 GrBackendTextureDesc desc; |
| 1113 desc.fFlags = kRenderTarget_GrBackendTextureFlag; | 1114 desc.fFlags = kRenderTarget_GrBackendTextureFlag; |
| 1114 desc.fWidth = resource_->size.width(); | 1115 desc.fWidth = resource_->size.width(); |
| 1115 desc.fHeight = resource_->size.height(); | 1116 desc.fHeight = resource_->size.height(); |
| 1116 desc.fConfig = ToGrPixelConfig(resource_->format); | 1117 desc.fConfig = ToGrPixelConfig(resource_->format); |
| 1117 desc.fOrigin = kTopLeft_GrSurfaceOrigin; | 1118 desc.fOrigin = kTopLeft_GrSurfaceOrigin; |
| 1118 desc.fTextureHandle = resource_->gl_id; | 1119 desc.fTextureHandle = resource_->gl_id; |
| 1120 desc.fSampleCnt = msaa_sample_count; |
| 1119 | 1121 |
| 1120 class GrContext* gr_context = resource_provider_->GrContext(); | 1122 class GrContext* gr_context = resource_provider_->GrContext(); |
| 1121 skia::RefPtr<GrTexture> gr_texture = | 1123 skia::RefPtr<GrTexture> gr_texture = |
| 1122 skia::AdoptRef(gr_context->wrapBackendTexture(desc)); | 1124 skia::AdoptRef(gr_context->wrapBackendTexture(desc)); |
| 1123 if (!gr_texture) | 1125 if (!gr_texture) |
| 1124 return nullptr; | 1126 return nullptr; |
| 1125 uint32_t flags = use_distance_field_text | 1127 uint32_t flags = use_distance_field_text |
| 1126 ? SkSurfaceProps::kUseDistanceFieldFonts_Flag | 1128 ? SkSurfaceProps::kUseDistanceFieldFonts_Flag |
| 1127 : 0; | 1129 : 0; |
| 1128 // Use unknown pixel geometry to disable LCD text. | 1130 // Use unknown pixel geometry to disable LCD text. |
| (...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2152 ContextProvider* context_provider = output_surface_->context_provider(); | 2154 ContextProvider* context_provider = output_surface_->context_provider(); |
| 2153 return context_provider ? context_provider->ContextGL() : NULL; | 2155 return context_provider ? context_provider->ContextGL() : NULL; |
| 2154 } | 2156 } |
| 2155 | 2157 |
| 2156 class GrContext* ResourceProvider::GrContext() const { | 2158 class GrContext* ResourceProvider::GrContext() const { |
| 2157 ContextProvider* context_provider = output_surface_->context_provider(); | 2159 ContextProvider* context_provider = output_surface_->context_provider(); |
| 2158 return context_provider ? context_provider->GrContext() : NULL; | 2160 return context_provider ? context_provider->GrContext() : NULL; |
| 2159 } | 2161 } |
| 2160 | 2162 |
| 2161 } // namespace cc | 2163 } // namespace cc |
| OLD | NEW |