OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/raster/raster_buffer_provider.h" | 5 #include "cc/raster/raster_buffer_provider.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
10 #include "cc/playback/raster_source.h" | 10 #include "cc/playback/raster_source.h" |
11 #include "cc/raster/texture_compressor.h" | 11 #include "cc/raster/texture_compressor.h" |
12 #include "cc/resources/platform_color.h" | 12 #include "cc/resources/platform_color.h" |
13 #include "cc/resources/resource_format_utils.h" | 13 #include "cc/resources/resource_format_utils.h" |
14 #include "third_party/skia/include/core/SkCanvas.h" | 14 #include "third_party/skia/include/core/SkCanvas.h" |
15 #include "third_party/skia/include/core/SkSurface.h" | 15 #include "third_party/skia/include/core/SkSurface.h" |
16 | 16 |
17 namespace cc { | 17 namespace cc { |
18 | 18 |
19 RasterBufferProvider::RasterBufferProvider() {} | 19 RasterBufferProvider::RasterBufferProvider() {} |
20 | 20 |
21 RasterBufferProvider::~RasterBufferProvider() {} | 21 RasterBufferProvider::~RasterBufferProvider() {} |
22 | 22 |
23 namespace { | 23 namespace { |
24 | 24 |
25 bool IsSupportedPlaybackToMemoryFormat(ResourceFormat format) { | 25 bool IsSupportedPlaybackToMemoryFormat(ResourceFormat format) { |
26 switch (format) { | 26 switch (format) { |
27 case RGBA_4444: | 27 case RGBA_4444: |
28 case RGBA_8888: | 28 case RGBA_8888: |
29 case BGRA_8888: | 29 case BGRA_8888: |
30 case RGBA_F16: | |
31 case ETC1: | 30 case ETC1: |
32 return true; | 31 return true; |
33 case ALPHA_8: | 32 case ALPHA_8: |
34 case LUMINANCE_8: | 33 case LUMINANCE_8: |
35 case RGB_565: | 34 case RGB_565: |
36 case RED_8: | 35 case RED_8: |
37 case LUMINANCE_F16: | 36 case LUMINANCE_F16: |
38 return false; | 37 return false; |
39 } | 38 } |
40 NOTREACHED(); | 39 NOTREACHED(); |
(...skipping 29 matching lines...) Expand all Loading... |
70 // LegacyFontHost will get LCD text and skia figures out what type to use. | 69 // LegacyFontHost will get LCD text and skia figures out what type to use. |
71 surface_props = SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType); | 70 surface_props = SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType); |
72 } | 71 } |
73 | 72 |
74 if (!stride) | 73 if (!stride) |
75 stride = info.minRowBytes(); | 74 stride = info.minRowBytes(); |
76 DCHECK_GT(stride, 0u); | 75 DCHECK_GT(stride, 0u); |
77 | 76 |
78 switch (format) { | 77 switch (format) { |
79 case RGBA_8888: | 78 case RGBA_8888: |
80 case BGRA_8888: | 79 case BGRA_8888: { |
81 case RGBA_F16: { | |
82 sk_sp<SkSurface> surface = | 80 sk_sp<SkSurface> surface = |
83 SkSurface::MakeRasterDirect(info, memory, stride, &surface_props); | 81 SkSurface::MakeRasterDirect(info, memory, stride, &surface_props); |
84 raster_source->PlaybackToCanvas(surface->getCanvas(), canvas_bitmap_rect, | 82 raster_source->PlaybackToCanvas(surface->getCanvas(), canvas_bitmap_rect, |
85 canvas_playback_rect, scale, | 83 canvas_playback_rect, scale, |
86 playback_settings); | 84 playback_settings); |
87 return; | 85 return; |
88 } | 86 } |
89 case RGBA_4444: | 87 case RGBA_4444: |
90 case ETC1: { | 88 case ETC1: { |
91 sk_sp<SkSurface> surface = SkSurface::MakeRaster(info, &surface_props); | 89 sk_sp<SkSurface> surface = SkSurface::MakeRaster(info, &surface_props); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 // Initialize resource using the preferred PlatformColor component | 136 // Initialize resource using the preferred PlatformColor component |
139 // order and swizzle in the shader instead of in software. | 137 // order and swizzle in the shader instead of in software. |
140 return !PlatformColor::SameComponentOrder(format); | 138 return !PlatformColor::SameComponentOrder(format); |
141 case RGBA_4444: | 139 case RGBA_4444: |
142 case ETC1: | 140 case ETC1: |
143 case ALPHA_8: | 141 case ALPHA_8: |
144 case LUMINANCE_8: | 142 case LUMINANCE_8: |
145 case RGB_565: | 143 case RGB_565: |
146 case RED_8: | 144 case RED_8: |
147 case LUMINANCE_F16: | 145 case LUMINANCE_F16: |
148 case RGBA_F16: | |
149 return false; | 146 return false; |
150 } | 147 } |
151 NOTREACHED(); | 148 NOTREACHED(); |
152 return false; | 149 return false; |
153 } | 150 } |
154 | 151 |
155 } // namespace cc | 152 } // namespace cc |
OLD | NEW |