| 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: |
| 30 case ETC1: | 31 case ETC1: |
| 31 return true; | 32 return true; |
| 32 case ALPHA_8: | 33 case ALPHA_8: |
| 33 case LUMINANCE_8: | 34 case LUMINANCE_8: |
| 34 case RGB_565: | 35 case RGB_565: |
| 35 case RED_8: | 36 case RED_8: |
| 36 case LUMINANCE_F16: | 37 case LUMINANCE_F16: |
| 37 return false; | 38 return false; |
| 38 } | 39 } |
| 39 NOTREACHED(); | 40 NOTREACHED(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 69 // LegacyFontHost will get LCD text and skia figures out what type to use. | 70 // LegacyFontHost will get LCD text and skia figures out what type to use. |
| 70 surface_props = SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType); | 71 surface_props = SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType); |
| 71 } | 72 } |
| 72 | 73 |
| 73 if (!stride) | 74 if (!stride) |
| 74 stride = info.minRowBytes(); | 75 stride = info.minRowBytes(); |
| 75 DCHECK_GT(stride, 0u); | 76 DCHECK_GT(stride, 0u); |
| 76 | 77 |
| 77 switch (format) { | 78 switch (format) { |
| 78 case RGBA_8888: | 79 case RGBA_8888: |
| 79 case BGRA_8888: { | 80 case BGRA_8888: |
| 81 case RGBA_F16: { |
| 80 sk_sp<SkSurface> surface = | 82 sk_sp<SkSurface> surface = |
| 81 SkSurface::MakeRasterDirect(info, memory, stride, &surface_props); | 83 SkSurface::MakeRasterDirect(info, memory, stride, &surface_props); |
| 82 raster_source->PlaybackToCanvas(surface->getCanvas(), canvas_bitmap_rect, | 84 raster_source->PlaybackToCanvas(surface->getCanvas(), canvas_bitmap_rect, |
| 83 canvas_playback_rect, scale, | 85 canvas_playback_rect, scale, |
| 84 playback_settings); | 86 playback_settings); |
| 85 return; | 87 return; |
| 86 } | 88 } |
| 87 case RGBA_4444: | 89 case RGBA_4444: |
| 88 case ETC1: { | 90 case ETC1: { |
| 89 sk_sp<SkSurface> surface = SkSurface::MakeRaster(info, &surface_props); | 91 sk_sp<SkSurface> surface = SkSurface::MakeRaster(info, &surface_props); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 // Initialize resource using the preferred PlatformColor component | 138 // Initialize resource using the preferred PlatformColor component |
| 137 // order and swizzle in the shader instead of in software. | 139 // order and swizzle in the shader instead of in software. |
| 138 return !PlatformColor::SameComponentOrder(format); | 140 return !PlatformColor::SameComponentOrder(format); |
| 139 case RGBA_4444: | 141 case RGBA_4444: |
| 140 case ETC1: | 142 case ETC1: |
| 141 case ALPHA_8: | 143 case ALPHA_8: |
| 142 case LUMINANCE_8: | 144 case LUMINANCE_8: |
| 143 case RGB_565: | 145 case RGB_565: |
| 144 case RED_8: | 146 case RED_8: |
| 145 case LUMINANCE_F16: | 147 case LUMINANCE_F16: |
| 148 case RGBA_F16: |
| 146 return false; | 149 return false; |
| 147 } | 150 } |
| 148 NOTREACHED(); | 151 NOTREACHED(); |
| 149 return false; | 152 return false; |
| 150 } | 153 } |
| 151 | 154 |
| 152 } // namespace cc | 155 } // namespace cc |
| OLD | NEW |