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/tile_task_worker_pool.h" | 5 #include "cc/raster/tile_task_worker_pool.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 "skia/ext/refptr.h" | |
13 #include "third_party/skia/include/core/SkCanvas.h" | 12 #include "third_party/skia/include/core/SkCanvas.h" |
14 #include "third_party/skia/include/core/SkSurface.h" | 13 #include "third_party/skia/include/core/SkSurface.h" |
15 | 14 |
16 namespace cc { | 15 namespace cc { |
17 | 16 |
18 TileTaskWorkerPool::TileTaskWorkerPool() {} | 17 TileTaskWorkerPool::TileTaskWorkerPool() {} |
19 | 18 |
20 TileTaskWorkerPool::~TileTaskWorkerPool() {} | 19 TileTaskWorkerPool::~TileTaskWorkerPool() {} |
21 | 20 |
22 // static | 21 // static |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 surface_props = SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType); | 84 surface_props = SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType); |
86 } | 85 } |
87 | 86 |
88 if (!stride) | 87 if (!stride) |
89 stride = info.minRowBytes(); | 88 stride = info.minRowBytes(); |
90 DCHECK_GT(stride, 0u); | 89 DCHECK_GT(stride, 0u); |
91 | 90 |
92 switch (format) { | 91 switch (format) { |
93 case RGBA_8888: | 92 case RGBA_8888: |
94 case BGRA_8888: { | 93 case BGRA_8888: { |
95 skia::RefPtr<SkSurface> surface = skia::AdoptRef( | 94 sk_sp<SkSurface> surface = |
96 SkSurface::NewRasterDirect(info, memory, stride, &surface_props)); | 95 SkSurface::MakeRasterDirect(info, memory, stride, &surface_props); |
97 raster_source->PlaybackToCanvas(surface->getCanvas(), canvas_bitmap_rect, | 96 raster_source->PlaybackToCanvas(surface->getCanvas(), canvas_bitmap_rect, |
98 canvas_playback_rect, scale, | 97 canvas_playback_rect, scale, |
99 playback_settings); | 98 playback_settings); |
100 return; | 99 return; |
101 } | 100 } |
102 case RGBA_4444: | 101 case RGBA_4444: |
103 case ETC1: { | 102 case ETC1: { |
104 skia::RefPtr<SkSurface> surface = | 103 sk_sp<SkSurface> surface = SkSurface::MakeRaster(info, &surface_props); |
105 skia::AdoptRef(SkSurface::NewRaster(info, &surface_props)); | |
106 // TODO(reveman): Improve partial raster support by reducing the size of | 104 // TODO(reveman): Improve partial raster support by reducing the size of |
107 // playback rect passed to PlaybackToCanvas. crbug.com/519070 | 105 // playback rect passed to PlaybackToCanvas. crbug.com/519070 |
108 raster_source->PlaybackToCanvas(surface->getCanvas(), canvas_bitmap_rect, | 106 raster_source->PlaybackToCanvas(surface->getCanvas(), canvas_bitmap_rect, |
109 canvas_bitmap_rect, scale, | 107 canvas_bitmap_rect, scale, |
110 playback_settings); | 108 playback_settings); |
111 | 109 |
112 if (format == ETC1) { | 110 if (format == ETC1) { |
113 TRACE_EVENT0("cc", | 111 TRACE_EVENT0("cc", |
114 "TileTaskWorkerPool::PlaybackToMemory::CompressETC1"); | 112 "TileTaskWorkerPool::PlaybackToMemory::CompressETC1"); |
115 DCHECK_EQ(size.width() % 4, 0); | 113 DCHECK_EQ(size.width() % 4, 0); |
116 DCHECK_EQ(size.height() % 4, 0); | 114 DCHECK_EQ(size.height() % 4, 0); |
117 scoped_ptr<TextureCompressor> texture_compressor = | 115 scoped_ptr<TextureCompressor> texture_compressor = |
118 TextureCompressor::Create(TextureCompressor::kFormatETC1); | 116 TextureCompressor::Create(TextureCompressor::kFormatETC1); |
119 texture_compressor->Compress(reinterpret_cast<const uint8_t*>( | 117 texture_compressor->Compress(reinterpret_cast<const uint8_t*>( |
120 surface->peekPixels(nullptr, nullptr)), | 118 surface->peekPixels(nullptr, nullptr)), |
121 reinterpret_cast<uint8_t*>(memory), | 119 reinterpret_cast<uint8_t*>(memory), |
122 size.width(), size.height(), | 120 size.width(), size.height(), |
123 TextureCompressor::kQualityHigh); | 121 TextureCompressor::kQualityHigh); |
124 } else { | 122 } else { |
125 TRACE_EVENT0("cc", | 123 TRACE_EVENT0("cc", |
126 "TileTaskWorkerPool::PlaybackToMemory::ConvertRGBA4444"); | 124 "TileTaskWorkerPool::PlaybackToMemory::ConvertRGBA4444"); |
127 SkImageInfo dst_info = SkImageInfo::Make( | 125 SkImageInfo dst_info = SkImageInfo::Make( |
128 info.width(), info.height(), ResourceFormatToSkColorType(format), | 126 info.width(), info.height(), ResourceFormatToSkColorType(format), |
129 info.alphaType(), info.profileType()); | 127 info.alphaType(), info.profileType()); |
130 bool rv = | 128 bool rv = surface->readPixels(dst_info, memory, stride, 0, 0); |
131 surface->getCanvas()->readPixels(dst_info, memory, stride, 0, 0); | |
132 DCHECK(rv); | 129 DCHECK(rv); |
133 } | 130 } |
134 return; | 131 return; |
135 } | 132 } |
136 case ALPHA_8: | 133 case ALPHA_8: |
137 case LUMINANCE_8: | 134 case LUMINANCE_8: |
138 case RGB_565: | 135 case RGB_565: |
139 case RED_8: | 136 case RED_8: |
140 case LUMINANCE_F16: | 137 case LUMINANCE_F16: |
141 NOTREACHED(); | 138 NOTREACHED(); |
142 return; | 139 return; |
143 } | 140 } |
144 | 141 |
145 NOTREACHED(); | 142 NOTREACHED(); |
146 } | 143 } |
147 | 144 |
148 } // namespace cc | 145 } // namespace cc |
OLD | NEW |