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

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: add trace event 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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 // static 180 // static
181 void TileTaskWorkerPool::PlaybackToMemory(void* memory, 181 void TileTaskWorkerPool::PlaybackToMemory(void* memory,
182 ResourceFormat format, 182 ResourceFormat format,
183 const gfx::Size& size, 183 const gfx::Size& size,
184 size_t stride, 184 size_t stride,
185 const RasterSource* raster_source, 185 const RasterSource* raster_source,
186 const gfx::Rect& canvas_bitmap_rect, 186 const gfx::Rect& canvas_bitmap_rect,
187 const gfx::Rect& canvas_playback_rect, 187 const gfx::Rect& canvas_playback_rect,
188 float scale, 188 float scale,
189 bool include_images) { 189 bool include_images) {
190 TRACE_EVENT0("cc", "TileTaskWorkerPool::PlaybackToMemory");
191
190 DCHECK(IsSupportedPlaybackToMemoryFormat(format)) << format; 192 DCHECK(IsSupportedPlaybackToMemoryFormat(format)) << format;
191 193
192 // Uses kPremul_SkAlphaType since the result is not known to be opaque. 194 // Uses kPremul_SkAlphaType since the result is not known to be opaque.
193 SkImageInfo info = 195 SkImageInfo info =
194 SkImageInfo::MakeN32(size.width(), size.height(), kPremul_SkAlphaType); 196 SkImageInfo::MakeN32(size.width(), size.height(), kPremul_SkAlphaType);
195 SkColorType buffer_color_type = ResourceFormatToSkColorType(format); 197 SkColorType buffer_color_type = ResourceFormatToSkColorType(format);
196 bool needs_copy = buffer_color_type != info.colorType(); 198 bool needs_copy = buffer_color_type != info.colorType();
197 199
198 // Use unknown pixel geometry to disable LCD text. 200 // Use unknown pixel geometry to disable LCD text.
199 SkSurfaceProps surface_props(0, kUnknown_SkPixelGeometry); 201 SkSurfaceProps surface_props(0, kUnknown_SkPixelGeometry);
(...skipping 17 matching lines...) Expand all
217 canvas->setDrawFilter(image_filter.get()); 219 canvas->setDrawFilter(image_filter.get());
218 raster_source->PlaybackToCanvas(canvas.get(), canvas_bitmap_rect, 220 raster_source->PlaybackToCanvas(canvas.get(), canvas_bitmap_rect,
219 canvas_playback_rect, scale); 221 canvas_playback_rect, scale);
220 return; 222 return;
221 } 223 }
222 224
223 skia::RefPtr<SkSurface> surface = 225 skia::RefPtr<SkSurface> surface =
224 skia::AdoptRef(SkSurface::NewRaster(info, &surface_props)); 226 skia::AdoptRef(SkSurface::NewRaster(info, &surface_props));
225 skia::RefPtr<SkCanvas> canvas = skia::SharePtr(surface->getCanvas()); 227 skia::RefPtr<SkCanvas> canvas = skia::SharePtr(surface->getCanvas());
226 canvas->setDrawFilter(image_filter.get()); 228 canvas->setDrawFilter(image_filter.get());
229 // TODO(reveman): Improve partial raster support by reducing the size of
230 // playback rect passed to PlaybackToCanvas. crbug.com/519070
227 raster_source->PlaybackToCanvas(canvas.get(), canvas_bitmap_rect, 231 raster_source->PlaybackToCanvas(canvas.get(), canvas_bitmap_rect,
228 canvas_playback_rect, scale); 232 canvas_bitmap_rect, scale);
229 233
230 SkImageInfo dst_info = 234 {
231 SkImageInfo::Make(info.width(), info.height(), buffer_color_type, 235 TRACE_EVENT0("cc", "TileTaskWorkerPool::PlaybackToMemory::ConvertPixels");
232 info.alphaType(), info.profileType()); 236
233 // TODO(kaanb): The GL pipeline assumes a 4-byte alignment for the 237 SkImageInfo dst_info =
234 // bitmap data. There will be no need to call SkAlign4 once crbug.com/293728 238 SkImageInfo::Make(info.width(), info.height(), buffer_color_type,
235 // is fixed. 239 info.alphaType(), info.profileType());
236 const size_t dst_row_bytes = SkAlign4(dst_info.minRowBytes()); 240 // TODO(kaanb): The GL pipeline assumes a 4-byte alignment for the
237 DCHECK_EQ(0u, dst_row_bytes % 4); 241 // bitmap data. There will be no need to call SkAlign4 once crbug.com/293728
238 bool success = canvas->readPixels(dst_info, memory, dst_row_bytes, 0, 0); 242 // is fixed.
239 DCHECK_EQ(true, success); 243 const size_t dst_row_bytes = SkAlign4(dst_info.minRowBytes());
244 DCHECK_EQ(0u, dst_row_bytes % 4);
245 bool success = canvas->readPixels(dst_info, memory, dst_row_bytes, 0, 0);
246 DCHECK_EQ(true, success);
247 }
240 } 248 }
241 249
242 } // namespace cc 250 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698