Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(379)

Side by Side Diff: cc/raster/tile_task_worker_pool.cc

Issue 1248253003: Add better support for RGBA_4444 textures. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase and forward flags Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <algorithm> 7 #include <algorithm>
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"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 // static 175 // static
176 void TileTaskWorkerPool::PlaybackToMemory(void* memory, 176 void TileTaskWorkerPool::PlaybackToMemory(void* memory,
177 ResourceFormat format, 177 ResourceFormat format,
178 const gfx::Size& size, 178 const gfx::Size& size,
179 size_t stride, 179 size_t stride,
180 const RasterSource* raster_source, 180 const RasterSource* raster_source,
181 const gfx::Rect& canvas_bitmap_rect, 181 const gfx::Rect& canvas_bitmap_rect,
182 const gfx::Rect& canvas_playback_rect, 182 const gfx::Rect& canvas_playback_rect,
183 float scale, 183 float scale,
184 bool include_images) { 184 bool include_images) {
185 TRACE_EVENT0("cc", "TileTaskWorkerPool::PlaybackToMemory");
186
185 DCHECK(IsSupportedPlaybackToMemoryFormat(format)) << format; 187 DCHECK(IsSupportedPlaybackToMemoryFormat(format)) << format;
186 188
187 // Uses kPremul_SkAlphaType since the result is not known to be opaque. 189 // Uses kPremul_SkAlphaType since the result is not known to be opaque.
188 SkImageInfo info = 190 SkImageInfo info =
189 SkImageInfo::MakeN32(size.width(), size.height(), kPremul_SkAlphaType); 191 SkImageInfo::MakeN32(size.width(), size.height(), kPremul_SkAlphaType);
190 SkColorType buffer_color_type = ResourceFormatToSkColorType(format); 192 SkColorType buffer_color_type = ResourceFormatToSkColorType(format);
191 bool needs_copy = buffer_color_type != info.colorType(); 193 bool needs_copy = buffer_color_type != info.colorType();
192 194
193 // Use unknown pixel geometry to disable LCD text. 195 // Use unknown pixel geometry to disable LCD text.
194 SkSurfaceProps surface_props(0, kUnknown_SkPixelGeometry); 196 SkSurfaceProps surface_props(0, kUnknown_SkPixelGeometry);
(...skipping 17 matching lines...) Expand all
212 canvas->setDrawFilter(image_filter.get()); 214 canvas->setDrawFilter(image_filter.get());
213 raster_source->PlaybackToCanvas(canvas.get(), canvas_bitmap_rect, 215 raster_source->PlaybackToCanvas(canvas.get(), canvas_bitmap_rect,
214 canvas_playback_rect, scale); 216 canvas_playback_rect, scale);
215 return; 217 return;
216 } 218 }
217 219
218 skia::RefPtr<SkSurface> surface = 220 skia::RefPtr<SkSurface> surface =
219 skia::AdoptRef(SkSurface::NewRaster(info, &surface_props)); 221 skia::AdoptRef(SkSurface::NewRaster(info, &surface_props));
220 skia::RefPtr<SkCanvas> canvas = skia::SharePtr(surface->getCanvas()); 222 skia::RefPtr<SkCanvas> canvas = skia::SharePtr(surface->getCanvas());
221 canvas->setDrawFilter(image_filter.get()); 223 canvas->setDrawFilter(image_filter.get());
224 // TODO(reveman): Improve partial raster support by reducing the size of
225 // playback rect passed to PlaybackToCanvas. crbug.com/519070
222 raster_source->PlaybackToCanvas(canvas.get(), canvas_bitmap_rect, 226 raster_source->PlaybackToCanvas(canvas.get(), canvas_bitmap_rect,
223 canvas_playback_rect, scale); 227 canvas_bitmap_rect, scale);
224 228
225 SkImageInfo dst_info = 229 {
226 SkImageInfo::Make(info.width(), info.height(), buffer_color_type, 230 TRACE_EVENT0("cc", "TileTaskWorkerPool::PlaybackToMemory::ConvertPixels");
227 info.alphaType(), info.profileType()); 231
228 // TODO(kaanb): The GL pipeline assumes a 4-byte alignment for the 232 SkImageInfo dst_info =
229 // bitmap data. There will be no need to call SkAlign4 once crbug.com/293728 233 SkImageInfo::Make(info.width(), info.height(), buffer_color_type,
230 // is fixed. 234 info.alphaType(), info.profileType());
231 const size_t dst_row_bytes = SkAlign4(dst_info.minRowBytes()); 235 // TODO(kaanb): The GL pipeline assumes a 4-byte alignment for the
232 DCHECK_EQ(0u, dst_row_bytes % 4); 236 // bitmap data. There will be no need to call SkAlign4 once crbug.com/293728
233 bool success = canvas->readPixels(dst_info, memory, dst_row_bytes, 0, 0); 237 // is fixed.
234 DCHECK_EQ(true, success); 238 const size_t dst_row_bytes = SkAlign4(dst_info.minRowBytes());
239 DCHECK_EQ(0u, dst_row_bytes % 4);
240 bool success = canvas->readPixels(dst_info, memory, dst_row_bytes, 0, 0);
241 DCHECK_EQ(true, success);
242 }
235 } 243 }
236 244
237 } // namespace cc 245 } // namespace cc
OLDNEW
« no previous file with comments | « cc/raster/one_copy_tile_task_worker_pool.cc ('k') | cc/raster/zero_copy_tile_task_worker_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698