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

Side by Side Diff: Source/platform/graphics/DeferredImageDecoder.cpp

Issue 531883002: use factories instead of manually setting fields (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « no previous file | Source/platform/graphics/ImageFrameGeneratorTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 } 259 }
260 } 260 }
261 261
262 // Creates a SkBitmap that is backed by SkDiscardablePixelRef. 262 // Creates a SkBitmap that is backed by SkDiscardablePixelRef.
263 SkBitmap DeferredImageDecoder::createBitmap(size_t index) 263 SkBitmap DeferredImageDecoder::createBitmap(size_t index)
264 { 264 {
265 IntSize decodedSize = m_actualDecoder->decodedSize(); 265 IntSize decodedSize = m_actualDecoder->decodedSize();
266 ASSERT(decodedSize.width() > 0); 266 ASSERT(decodedSize.width() > 0);
267 ASSERT(decodedSize.height() > 0); 267 ASSERT(decodedSize.height() > 0);
268 268
269 SkImageInfo info;
270 info.fWidth = decodedSize.width();
271 info.fHeight = decodedSize.height();
272 #if SK_B32_SHIFT // Little-endian RGBA pixels. (Android) 269 #if SK_B32_SHIFT // Little-endian RGBA pixels. (Android)
273 info.fColorType = kRGBA_8888_SkColorType; 270 const SkColorType colorType = kRGBA_8888_SkColorType;
274 #else 271 #else
275 info.fColorType = kBGRA_8888_SkColorType; 272 const SkColorType colorType = kBGRA_8888_SkColorType;
276 #endif 273 #endif
277 info.fAlphaType = kPremul_SkAlphaType; 274 const SkImageInfo info = SkImageInfo::Make(decodedSize.width(), decodedSize. height(), colorType, kPremul_SkAlphaType);
278 275
279 SkBitmap bitmap; 276 SkBitmap bitmap;
280 DecodingImageGenerator* generator = new DecodingImageGenerator(m_frameGenera tor, info, index); 277 DecodingImageGenerator* generator = new DecodingImageGenerator(m_frameGenera tor, info, index);
281 bool installed = SkInstallDiscardablePixelRef(generator, &bitmap); 278 bool installed = SkInstallDiscardablePixelRef(generator, &bitmap);
282 ASSERT_UNUSED(installed, installed); 279 ASSERT_UNUSED(installed, installed);
283 bitmap.pixelRef()->setURI(labelDiscardable); 280 bitmap.pixelRef()->setURI(labelDiscardable);
284 generator->setGenerationId(bitmap.getGenerationID()); 281 generator->setGenerationId(bitmap.getGenerationID());
285 return bitmap; 282 return bitmap;
286 } 283 }
287 284
288 bool DeferredImageDecoder::hotSpot(IntPoint& hotSpot) const 285 bool DeferredImageDecoder::hotSpot(IntPoint& hotSpot) const
289 { 286 {
290 // TODO: Implement. 287 // TODO: Implement.
291 return m_actualDecoder ? m_actualDecoder->hotSpot(hotSpot) : false; 288 return m_actualDecoder ? m_actualDecoder->hotSpot(hotSpot) : false;
292 } 289 }
293 290
294 } // namespace blink 291 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | Source/platform/graphics/ImageFrameGeneratorTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698