| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1155 if (use_mailbox_) | 1155 if (use_mailbox_) |
| 1156 gl_->DeleteTextures(1, &texture_id_); | 1156 gl_->DeleteTextures(1, &texture_id_); |
| 1157 } | 1157 } |
| 1158 | 1158 |
| 1159 ResourceProvider::ScopedSkSurfaceProvider::ScopedSkSurfaceProvider( | 1159 ResourceProvider::ScopedSkSurfaceProvider::ScopedSkSurfaceProvider( |
| 1160 ContextProvider* context_provider, | 1160 ContextProvider* context_provider, |
| 1161 ScopedWriteLockGL* resource_lock, | 1161 ScopedWriteLockGL* resource_lock, |
| 1162 bool use_mailbox, | 1162 bool use_mailbox, |
| 1163 bool use_distance_field_text, | 1163 bool use_distance_field_text, |
| 1164 bool can_use_lcd_text, | 1164 bool can_use_lcd_text, |
| 1165 bool ignore_color_space, |
| 1165 int msaa_sample_count) | 1166 int msaa_sample_count) |
| 1166 : texture_provider_(context_provider->ContextGL(), | 1167 : texture_provider_(context_provider->ContextGL(), |
| 1167 resource_lock, | 1168 resource_lock, |
| 1168 use_mailbox) { | 1169 use_mailbox) { |
| 1169 GrGLTextureInfo texture_info; | 1170 GrGLTextureInfo texture_info; |
| 1170 texture_info.fID = texture_provider_.texture_id(); | 1171 texture_info.fID = texture_provider_.texture_id(); |
| 1171 texture_info.fTarget = resource_lock->target(); | 1172 texture_info.fTarget = resource_lock->target(); |
| 1172 GrBackendTextureDesc desc; | 1173 GrBackendTextureDesc desc; |
| 1173 desc.fFlags = kRenderTarget_GrBackendTextureFlag; | 1174 desc.fFlags = kRenderTarget_GrBackendTextureFlag; |
| 1174 desc.fWidth = resource_lock->size().width(); | 1175 desc.fWidth = resource_lock->size().width(); |
| 1175 desc.fHeight = resource_lock->size().height(); | 1176 desc.fHeight = resource_lock->size().height(); |
| 1176 desc.fConfig = ToGrPixelConfig(resource_lock->format()); | 1177 desc.fConfig = ToGrPixelConfig(resource_lock->format()); |
| 1177 desc.fOrigin = kTopLeft_GrSurfaceOrigin; | 1178 desc.fOrigin = kTopLeft_GrSurfaceOrigin; |
| 1178 desc.fTextureHandle = skia::GrGLTextureInfoToGrBackendObject(texture_info); | 1179 desc.fTextureHandle = skia::GrGLTextureInfoToGrBackendObject(texture_info); |
| 1179 desc.fSampleCnt = msaa_sample_count; | 1180 desc.fSampleCnt = msaa_sample_count; |
| 1180 | 1181 |
| 1181 uint32_t flags = | 1182 uint32_t flags = |
| 1182 use_distance_field_text ? SkSurfaceProps::kUseDistanceFieldFonts_Flag : 0; | 1183 use_distance_field_text ? SkSurfaceProps::kUseDistanceFieldFonts_Flag : 0; |
| 1183 // Use unknown pixel geometry to disable LCD text. | 1184 // Use unknown pixel geometry to disable LCD text. |
| 1184 SkSurfaceProps surface_props(flags, kUnknown_SkPixelGeometry); | 1185 SkSurfaceProps surface_props(flags, kUnknown_SkPixelGeometry); |
| 1185 if (can_use_lcd_text) { | 1186 if (can_use_lcd_text) { |
| 1186 // LegacyFontHost will get LCD text and skia figures out what type to use. | 1187 // LegacyFontHost will get LCD text and skia figures out what type to use. |
| 1187 surface_props = | 1188 surface_props = |
| 1188 SkSurfaceProps(flags, SkSurfaceProps::kLegacyFontHost_InitType); | 1189 SkSurfaceProps(flags, SkSurfaceProps::kLegacyFontHost_InitType); |
| 1189 } | 1190 } |
| 1190 sk_surface_ = SkSurface::MakeFromBackendTextureAsRenderTarget( | 1191 sk_surface_ = SkSurface::MakeFromBackendTextureAsRenderTarget( |
| 1191 context_provider->GrContext(), desc, resource_lock->sk_color_space(), | 1192 context_provider->GrContext(), desc, |
| 1193 ignore_color_space ? nullptr : resource_lock->sk_color_space(), |
| 1192 &surface_props); | 1194 &surface_props); |
| 1193 } | 1195 } |
| 1194 | 1196 |
| 1195 ResourceProvider::ScopedSkSurfaceProvider::~ScopedSkSurfaceProvider() { | 1197 ResourceProvider::ScopedSkSurfaceProvider::~ScopedSkSurfaceProvider() { |
| 1196 if (sk_surface_.get()) { | 1198 if (sk_surface_.get()) { |
| 1197 sk_surface_->prepareForExternalIO(); | 1199 sk_surface_->prepareForExternalIO(); |
| 1198 sk_surface_.reset(); | 1200 sk_surface_.reset(); |
| 1199 } | 1201 } |
| 1200 } | 1202 } |
| 1201 | 1203 |
| (...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2062 | 2064 |
| 2063 const int kImportance = 2; | 2065 const int kImportance = 2; |
| 2064 pmd->CreateSharedGlobalAllocatorDump(guid); | 2066 pmd->CreateSharedGlobalAllocatorDump(guid); |
| 2065 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); | 2067 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); |
| 2066 } | 2068 } |
| 2067 | 2069 |
| 2068 return true; | 2070 return true; |
| 2069 } | 2071 } |
| 2070 | 2072 |
| 2071 } // namespace cc | 2073 } // namespace cc |
| OLD | NEW |