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 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1118 | 1118 |
1119 GrBackendTextureDesc desc; | 1119 GrBackendTextureDesc desc; |
1120 desc.fFlags = kRenderTarget_GrBackendTextureFlag; | 1120 desc.fFlags = kRenderTarget_GrBackendTextureFlag; |
1121 desc.fWidth = resource_->size.width(); | 1121 desc.fWidth = resource_->size.width(); |
1122 desc.fHeight = resource_->size.height(); | 1122 desc.fHeight = resource_->size.height(); |
1123 desc.fConfig = ToGrPixelConfig(resource_->format); | 1123 desc.fConfig = ToGrPixelConfig(resource_->format); |
1124 desc.fOrigin = kTopLeft_GrSurfaceOrigin; | 1124 desc.fOrigin = kTopLeft_GrSurfaceOrigin; |
1125 desc.fTextureHandle = resource_->gl_id; | 1125 desc.fTextureHandle = resource_->gl_id; |
1126 skia::RefPtr<GrTexture> gr_texture = | 1126 skia::RefPtr<GrTexture> gr_texture = |
1127 skia::AdoptRef(gr_context->wrapBackendTexture(desc)); | 1127 skia::AdoptRef(gr_context->wrapBackendTexture(desc)); |
| 1128 if (!gr_texture) |
| 1129 return nullptr; |
1128 SkSurface::TextRenderMode text_render_mode = | 1130 SkSurface::TextRenderMode text_render_mode = |
1129 use_distance_field_text ? SkSurface::kDistanceField_TextRenderMode | 1131 use_distance_field_text ? SkSurface::kDistanceField_TextRenderMode |
1130 : SkSurface::kStandard_TextRenderMode; | 1132 : SkSurface::kStandard_TextRenderMode; |
1131 resource_->sk_surface = skia::AdoptRef(SkSurface::NewRenderTargetDirect( | 1133 resource_->sk_surface = skia::AdoptRef(SkSurface::NewRenderTargetDirect( |
1132 gr_texture->asRenderTarget(), text_render_mode)); | 1134 gr_texture->asRenderTarget(), text_render_mode)); |
1133 } | 1135 } |
1134 return resource_->sk_surface.get(); | 1136 return resource_->sk_surface.get(); |
1135 } | 1137 } |
1136 | 1138 |
1137 ResourceProvider::SynchronousFence::SynchronousFence( | 1139 ResourceProvider::SynchronousFence::SynchronousFence( |
(...skipping 984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2122 ContextProvider* context_provider = output_surface_->context_provider(); | 2124 ContextProvider* context_provider = output_surface_->context_provider(); |
2123 return context_provider ? context_provider->ContextGL() : NULL; | 2125 return context_provider ? context_provider->ContextGL() : NULL; |
2124 } | 2126 } |
2125 | 2127 |
2126 class GrContext* ResourceProvider::GrContext() const { | 2128 class GrContext* ResourceProvider::GrContext() const { |
2127 ContextProvider* context_provider = output_surface_->context_provider(); | 2129 ContextProvider* context_provider = output_surface_->context_provider(); |
2128 return context_provider ? context_provider->GrContext() : NULL; | 2130 return context_provider ? context_provider->GrContext() : NULL; |
2129 } | 2131 } |
2130 | 2132 |
2131 } // namespace cc | 2133 } // namespace cc |
OLD | NEW |