| 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 1208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1219 if (use_mailbox_) | 1219 if (use_mailbox_) |
| 1220 gl_->DeleteTextures(1, &texture_id_); | 1220 gl_->DeleteTextures(1, &texture_id_); |
| 1221 } | 1221 } |
| 1222 | 1222 |
| 1223 ResourceProvider::ScopedSkSurfaceProvider::ScopedSkSurfaceProvider( | 1223 ResourceProvider::ScopedSkSurfaceProvider::ScopedSkSurfaceProvider( |
| 1224 ContextProvider* context_provider, | 1224 ContextProvider* context_provider, |
| 1225 ScopedWriteLockGL* resource_lock, | 1225 ScopedWriteLockGL* resource_lock, |
| 1226 bool use_mailbox, | 1226 bool use_mailbox, |
| 1227 bool use_distance_field_text, | 1227 bool use_distance_field_text, |
| 1228 bool can_use_lcd_text, | 1228 bool can_use_lcd_text, |
| 1229 bool ignore_color_space, | |
| 1230 int msaa_sample_count) | 1229 int msaa_sample_count) |
| 1231 : texture_provider_(context_provider->ContextGL(), | 1230 : texture_provider_(context_provider->ContextGL(), |
| 1232 resource_lock, | 1231 resource_lock, |
| 1233 use_mailbox) { | 1232 use_mailbox) { |
| 1234 GrGLTextureInfo texture_info; | 1233 GrGLTextureInfo texture_info; |
| 1235 texture_info.fID = texture_provider_.texture_id(); | 1234 texture_info.fID = texture_provider_.texture_id(); |
| 1236 texture_info.fTarget = resource_lock->target(); | 1235 texture_info.fTarget = resource_lock->target(); |
| 1237 GrBackendTextureDesc desc; | 1236 GrBackendTextureDesc desc; |
| 1238 desc.fFlags = kRenderTarget_GrBackendTextureFlag; | 1237 desc.fFlags = kRenderTarget_GrBackendTextureFlag; |
| 1239 desc.fWidth = resource_lock->size().width(); | 1238 desc.fWidth = resource_lock->size().width(); |
| 1240 desc.fHeight = resource_lock->size().height(); | 1239 desc.fHeight = resource_lock->size().height(); |
| 1241 desc.fConfig = ToGrPixelConfig(resource_lock->format()); | 1240 desc.fConfig = ToGrPixelConfig(resource_lock->format()); |
| 1242 desc.fOrigin = kTopLeft_GrSurfaceOrigin; | 1241 desc.fOrigin = kTopLeft_GrSurfaceOrigin; |
| 1243 desc.fTextureHandle = skia::GrGLTextureInfoToGrBackendObject(texture_info); | 1242 desc.fTextureHandle = skia::GrGLTextureInfoToGrBackendObject(texture_info); |
| 1244 desc.fSampleCnt = msaa_sample_count; | 1243 desc.fSampleCnt = msaa_sample_count; |
| 1245 | 1244 |
| 1246 uint32_t flags = | 1245 uint32_t flags = |
| 1247 use_distance_field_text ? SkSurfaceProps::kUseDistanceFieldFonts_Flag : 0; | 1246 use_distance_field_text ? SkSurfaceProps::kUseDistanceFieldFonts_Flag : 0; |
| 1248 // Use unknown pixel geometry to disable LCD text. | 1247 // Use unknown pixel geometry to disable LCD text. |
| 1249 SkSurfaceProps surface_props(flags, kUnknown_SkPixelGeometry); | 1248 SkSurfaceProps surface_props(flags, kUnknown_SkPixelGeometry); |
| 1250 if (can_use_lcd_text) { | 1249 if (can_use_lcd_text) { |
| 1251 // LegacyFontHost will get LCD text and skia figures out what type to use. | 1250 // LegacyFontHost will get LCD text and skia figures out what type to use. |
| 1252 surface_props = | 1251 surface_props = |
| 1253 SkSurfaceProps(flags, SkSurfaceProps::kLegacyFontHost_InitType); | 1252 SkSurfaceProps(flags, SkSurfaceProps::kLegacyFontHost_InitType); |
| 1254 } | 1253 } |
| 1255 sk_surface_ = SkSurface::MakeFromBackendTextureAsRenderTarget( | 1254 sk_surface_ = SkSurface::MakeFromBackendTextureAsRenderTarget( |
| 1256 context_provider->GrContext(), desc, | 1255 context_provider->GrContext(), desc, resource_lock->sk_color_space(), |
| 1257 ignore_color_space ? nullptr : resource_lock->sk_color_space(), | |
| 1258 &surface_props); | 1256 &surface_props); |
| 1259 } | 1257 } |
| 1260 | 1258 |
| 1261 ResourceProvider::ScopedSkSurfaceProvider::~ScopedSkSurfaceProvider() { | 1259 ResourceProvider::ScopedSkSurfaceProvider::~ScopedSkSurfaceProvider() { |
| 1262 if (sk_surface_.get()) { | 1260 if (sk_surface_.get()) { |
| 1263 sk_surface_->prepareForExternalIO(); | 1261 sk_surface_->prepareForExternalIO(); |
| 1264 sk_surface_.reset(); | 1262 sk_surface_.reset(); |
| 1265 } | 1263 } |
| 1266 } | 1264 } |
| 1267 | 1265 |
| (...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2174 | 2172 |
| 2175 const int kImportance = 2; | 2173 const int kImportance = 2; |
| 2176 pmd->CreateSharedGlobalAllocatorDump(guid); | 2174 pmd->CreateSharedGlobalAllocatorDump(guid); |
| 2177 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); | 2175 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); |
| 2178 } | 2176 } |
| 2179 | 2177 |
| 2180 return true; | 2178 return true; |
| 2181 } | 2179 } |
| 2182 | 2180 |
| 2183 } // namespace cc | 2181 } // namespace cc |
| OLD | NEW |