| 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/resources/raster_worker_pool.h" | 5 #include "cc/resources/raster_worker_pool.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 const gfx::Rect& rect, | 221 const gfx::Rect& rect, |
| 222 float scale) { | 222 float scale) { |
| 223 DCHECK(IsSupportedPlaybackToMemoryFormat(format)) << format; | 223 DCHECK(IsSupportedPlaybackToMemoryFormat(format)) << format; |
| 224 | 224 |
| 225 // Uses kPremul_SkAlphaType since the result is not known to be opaque. | 225 // Uses kPremul_SkAlphaType since the result is not known to be opaque. |
| 226 SkImageInfo info = | 226 SkImageInfo info = |
| 227 SkImageInfo::MakeN32(size.width(), size.height(), kPremul_SkAlphaType); | 227 SkImageInfo::MakeN32(size.width(), size.height(), kPremul_SkAlphaType); |
| 228 SkColorType buffer_color_type = ResourceFormatToSkColorType(format); | 228 SkColorType buffer_color_type = ResourceFormatToSkColorType(format); |
| 229 bool needs_copy = buffer_color_type != info.colorType(); | 229 bool needs_copy = buffer_color_type != info.colorType(); |
| 230 | 230 |
| 231 // Use unknown pixel geometry to disable LCD text. | 231 // TODO(danakj): Make a SkSurfaceProps with an SkPixelGeometry to enable or |
| 232 SkSurfaceProps surface_props(0, kUnknown_SkPixelGeometry); | 232 // disable LCD text. |
| 233 if (raster_source->CanUseLCDText()) { | 233 // TODO(danakj): Disable LCD text on Mac during layout tests: |
| 234 // LegacyFontHost will get LCD text and skia figures out what type to use. | 234 // https://cs.chromium.org#chromium/src/third_party/WebKit/Source/platform/fon
ts/mac/FontPlatformDataMac.mm&l=55 |
| 235 surface_props = SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType); | 235 // TODO(danakj): On Windows when LCD text is disabled, ask skia to draw LCD |
| 236 } | 236 // text offscreen and downsample it to AA text. |
| 237 // https://cs.chromium.org#chromium/src/third_party/WebKit/Source/platform/fon
ts/win/FontPlatformDataWin.cpp&l=86 |
| 238 SkSurfaceProps* surface_props = nullptr; |
| 237 | 239 |
| 238 if (!stride) | 240 if (!stride) |
| 239 stride = info.minRowBytes(); | 241 stride = info.minRowBytes(); |
| 240 | 242 |
| 241 if (!needs_copy) { | 243 if (!needs_copy) { |
| 242 skia::RefPtr<SkSurface> surface = skia::AdoptRef( | 244 skia::RefPtr<SkSurface> surface = skia::AdoptRef( |
| 243 SkSurface::NewRasterDirect(info, memory, stride, &surface_props)); | 245 SkSurface::NewRasterDirect(info, memory, stride, surface_props)); |
| 244 skia::RefPtr<SkCanvas> canvas = skia::SharePtr(surface->getCanvas()); | 246 skia::RefPtr<SkCanvas> canvas = skia::SharePtr(surface->getCanvas()); |
| 245 raster_source->PlaybackToCanvas(canvas.get(), rect, scale); | 247 raster_source->PlaybackToCanvas(canvas.get(), rect, scale); |
| 246 return; | 248 return; |
| 247 } | 249 } |
| 248 | 250 |
| 249 skia::RefPtr<SkSurface> surface = | 251 skia::RefPtr<SkSurface> surface = |
| 250 skia::AdoptRef(SkSurface::NewRaster(info, &surface_props)); | 252 skia::AdoptRef(SkSurface::NewRaster(info, surface_props)); |
| 251 skia::RefPtr<SkCanvas> canvas = skia::SharePtr(surface->getCanvas()); | 253 skia::RefPtr<SkCanvas> canvas = skia::SharePtr(surface->getCanvas()); |
| 252 raster_source->PlaybackToCanvas(canvas.get(), rect, scale); | 254 raster_source->PlaybackToCanvas(canvas.get(), rect, scale); |
| 253 | 255 |
| 254 SkImageInfo dst_info = info; | 256 SkImageInfo dst_info = info; |
| 255 dst_info.fColorType = buffer_color_type; | 257 dst_info.fColorType = buffer_color_type; |
| 256 // TODO(kaanb): The GL pipeline assumes a 4-byte alignment for the | 258 // TODO(kaanb): The GL pipeline assumes a 4-byte alignment for the |
| 257 // bitmap data. There will be no need to call SkAlign4 once crbug.com/293728 | 259 // bitmap data. There will be no need to call SkAlign4 once crbug.com/293728 |
| 258 // is fixed. | 260 // is fixed. |
| 259 const size_t dst_row_bytes = SkAlign4(dst_info.minRowBytes()); | 261 const size_t dst_row_bytes = SkAlign4(dst_info.minRowBytes()); |
| 260 DCHECK_EQ(0u, dst_row_bytes % 4); | 262 DCHECK_EQ(0u, dst_row_bytes % 4); |
| 261 bool success = canvas->readPixels(dst_info, memory, dst_row_bytes, 0, 0); | 263 bool success = canvas->readPixels(dst_info, memory, dst_row_bytes, 0, 0); |
| 262 DCHECK_EQ(true, success); | 264 DCHECK_EQ(true, success); |
| 263 } | 265 } |
| 264 | 266 |
| 265 } // namespace cc | 267 } // namespace cc |
| OLD | NEW |