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/base/scale_translate2d.h" |
10 #include "cc/raster/raster_source.h" | 11 #include "cc/raster/raster_source.h" |
11 #include "cc/raster/texture_compressor.h" | 12 #include "cc/raster/texture_compressor.h" |
12 #include "cc/resources/platform_color.h" | 13 #include "cc/resources/platform_color.h" |
13 #include "cc/resources/resource_format_utils.h" | 14 #include "cc/resources/resource_format_utils.h" |
14 #include "third_party/skia/include/core/SkCanvas.h" | 15 #include "third_party/skia/include/core/SkCanvas.h" |
15 #include "third_party/skia/include/core/SkSurface.h" | 16 #include "third_party/skia/include/core/SkSurface.h" |
16 | 17 |
17 namespace cc { | 18 namespace cc { |
18 | 19 |
19 RasterBufferProvider::RasterBufferProvider() {} | 20 RasterBufferProvider::RasterBufferProvider() {} |
(...skipping 25 matching lines...) Expand all Loading... |
45 | 46 |
46 // static | 47 // static |
47 void RasterBufferProvider::PlaybackToMemory( | 48 void RasterBufferProvider::PlaybackToMemory( |
48 void* memory, | 49 void* memory, |
49 ResourceFormat format, | 50 ResourceFormat format, |
50 const gfx::Size& size, | 51 const gfx::Size& size, |
51 size_t stride, | 52 size_t stride, |
52 const RasterSource* raster_source, | 53 const RasterSource* raster_source, |
53 const gfx::Rect& canvas_bitmap_rect, | 54 const gfx::Rect& canvas_bitmap_rect, |
54 const gfx::Rect& canvas_playback_rect, | 55 const gfx::Rect& canvas_playback_rect, |
55 float scale, | 56 const ScaleTranslate2d& transform, |
56 const gfx::ColorSpace& target_color_space, | 57 const gfx::ColorSpace& target_color_space, |
57 const RasterSource::PlaybackSettings& playback_settings) { | 58 const RasterSource::PlaybackSettings& playback_settings) { |
58 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"), | 59 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"), |
59 "RasterBufferProvider::PlaybackToMemory"); | 60 "RasterBufferProvider::PlaybackToMemory"); |
60 | 61 |
61 DCHECK(IsSupportedPlaybackToMemoryFormat(format)) << format; | 62 DCHECK(IsSupportedPlaybackToMemoryFormat(format)) << format; |
62 | 63 |
63 // Uses kPremul_SkAlphaType since the result is not known to be opaque. | 64 // Uses kPremul_SkAlphaType since the result is not known to be opaque. |
64 SkImageInfo info = | 65 SkImageInfo info = |
65 SkImageInfo::MakeN32(size.width(), size.height(), kPremul_SkAlphaType); | 66 SkImageInfo::MakeN32(size.width(), size.height(), kPremul_SkAlphaType); |
(...skipping 10 matching lines...) Expand all Loading... |
76 DCHECK_GT(stride, 0u); | 77 DCHECK_GT(stride, 0u); |
77 | 78 |
78 switch (format) { | 79 switch (format) { |
79 case RGBA_8888: | 80 case RGBA_8888: |
80 case BGRA_8888: | 81 case BGRA_8888: |
81 case RGBA_F16: { | 82 case RGBA_F16: { |
82 sk_sp<SkSurface> surface = | 83 sk_sp<SkSurface> surface = |
83 SkSurface::MakeRasterDirect(info, memory, stride, &surface_props); | 84 SkSurface::MakeRasterDirect(info, memory, stride, &surface_props); |
84 raster_source->PlaybackToCanvas(surface->getCanvas(), target_color_space, | 85 raster_source->PlaybackToCanvas(surface->getCanvas(), target_color_space, |
85 canvas_bitmap_rect, canvas_playback_rect, | 86 canvas_bitmap_rect, canvas_playback_rect, |
86 scale, playback_settings); | 87 transform, playback_settings); |
87 return; | 88 return; |
88 } | 89 } |
89 case RGBA_4444: | 90 case RGBA_4444: |
90 case ETC1: { | 91 case ETC1: { |
91 sk_sp<SkSurface> surface = SkSurface::MakeRaster(info, &surface_props); | 92 sk_sp<SkSurface> surface = SkSurface::MakeRaster(info, &surface_props); |
92 // TODO(reveman): Improve partial raster support by reducing the size of | 93 // TODO(reveman): Improve partial raster support by reducing the size of |
93 // playback rect passed to PlaybackToCanvas. crbug.com/519070 | 94 // playback rect passed to PlaybackToCanvas. crbug.com/519070 |
94 raster_source->PlaybackToCanvas(surface->getCanvas(), target_color_space, | 95 raster_source->PlaybackToCanvas(surface->getCanvas(), target_color_space, |
95 canvas_bitmap_rect, canvas_bitmap_rect, | 96 canvas_bitmap_rect, canvas_bitmap_rect, |
96 scale, playback_settings); | 97 transform, playback_settings); |
97 | 98 |
98 if (format == ETC1) { | 99 if (format == ETC1) { |
99 TRACE_EVENT0("cc", | 100 TRACE_EVENT0("cc", |
100 "RasterBufferProvider::PlaybackToMemory::CompressETC1"); | 101 "RasterBufferProvider::PlaybackToMemory::CompressETC1"); |
101 DCHECK_EQ(size.width() % 4, 0); | 102 DCHECK_EQ(size.width() % 4, 0); |
102 DCHECK_EQ(size.height() % 4, 0); | 103 DCHECK_EQ(size.height() % 4, 0); |
103 std::unique_ptr<TextureCompressor> texture_compressor = | 104 std::unique_ptr<TextureCompressor> texture_compressor = |
104 TextureCompressor::Create(TextureCompressor::kFormatETC1); | 105 TextureCompressor::Create(TextureCompressor::kFormatETC1); |
105 SkPixmap pixmap; | 106 SkPixmap pixmap; |
106 surface->peekPixels(&pixmap); | 107 surface->peekPixels(&pixmap); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 case RED_8: | 147 case RED_8: |
147 case LUMINANCE_F16: | 148 case LUMINANCE_F16: |
148 case RGBA_F16: | 149 case RGBA_F16: |
149 return false; | 150 return false; |
150 } | 151 } |
151 NOTREACHED(); | 152 NOTREACHED(); |
152 return false; | 153 return false; |
153 } | 154 } |
154 | 155 |
155 } // namespace cc | 156 } // namespace cc |
OLD | NEW |