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

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

Issue 1001703003: Take NativeImageSkia out behind the woodshed. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Switch to skia-style API (return bool instead of SkBitmap) Created 5 years, 9 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 | Annotate | Revision Log
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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 bool DeferredImageDecoder::enabled() 81 bool DeferredImageDecoder::enabled()
82 { 82 {
83 return s_enabled; 83 return s_enabled;
84 } 84 }
85 85
86 String DeferredImageDecoder::filenameExtension() const 86 String DeferredImageDecoder::filenameExtension() const
87 { 87 {
88 return m_actualDecoder ? m_actualDecoder->filenameExtension() : m_filenameEx tension; 88 return m_actualDecoder ? m_actualDecoder->filenameExtension() : m_filenameEx tension;
89 } 89 }
90 90
91 PassRefPtr<NativeImageSkia> DeferredImageDecoder::createFrameAtIndex(size_t inde x) 91 bool DeferredImageDecoder::createFrameAtIndex(size_t index, SkBitmap* bitmap)
92 { 92 {
93 prepareLazyDecodedFrames(); 93 prepareLazyDecodedFrames();
94 if (index < m_frameData.size()) { 94 if (index < m_frameData.size()) {
95 // ImageFrameGenerator has the latest known alpha state. There will 95 // ImageFrameGenerator has the latest known alpha state. There will
96 // be a performance boost if this frame is opaque. 96 // be a performance boost if this frame is opaque.
97 SkBitmap bitmap = createBitmap(index); 97 *bitmap = createBitmap(index);
98 if (m_frameGenerator->hasAlpha(index)) { 98 if (m_frameGenerator->hasAlpha(index)) {
99 m_frameData[index].m_hasAlpha = true; 99 m_frameData[index].m_hasAlpha = true;
100 bitmap.setAlphaType(kPremul_SkAlphaType); 100 bitmap->setAlphaType(kPremul_SkAlphaType);
101 } else { 101 } else {
102 m_frameData[index].m_hasAlpha = false; 102 m_frameData[index].m_hasAlpha = false;
103 bitmap.setAlphaType(kOpaque_SkAlphaType); 103 bitmap->setAlphaType(kOpaque_SkAlphaType);
104 } 104 }
105 m_frameData[index].m_frameBytes = m_size.area() * sizeof(ImageFrame::Pi xelData); 105 m_frameData[index].m_frameBytes = m_size.area() * sizeof(ImageFrame::Pi xelData);
106 return NativeImageSkia::create(bitmap); 106 return true;
107 } 107 }
108 if (m_actualDecoder) { 108 if (m_actualDecoder) {
109 ImageFrame* buffer = m_actualDecoder->frameBufferAtIndex(index); 109 ImageFrame* buffer = m_actualDecoder->frameBufferAtIndex(index);
110 if (!buffer || buffer->status() == ImageFrame::FrameEmpty) 110 if (!buffer || buffer->status() == ImageFrame::FrameEmpty)
111 return nullptr; 111 return false;
112 return buffer->asNewNativeImage(); 112 *bitmap = buffer->bitmap();
113 return true;
113 } 114 }
114 return nullptr; 115 return false;
115 } 116 }
116 117
117 void DeferredImageDecoder::setData(SharedBuffer& data, bool allDataReceived) 118 void DeferredImageDecoder::setData(SharedBuffer& data, bool allDataReceived)
118 { 119 {
119 if (m_actualDecoder) { 120 if (m_actualDecoder) {
120 m_data = RefPtr<SharedBuffer>(data); 121 m_data = RefPtr<SharedBuffer>(data);
121 m_lastDataSize = data.size(); 122 m_lastDataSize = data.size();
122 m_allDataReceived = allDataReceived; 123 m_allDataReceived = allDataReceived;
123 m_actualDecoder->setData(&data, allDataReceived); 124 m_actualDecoder->setData(&data, allDataReceived);
124 prepareLazyDecodedFrames(); 125 prepareLazyDecodedFrames();
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 return bitmap; 295 return bitmap;
295 } 296 }
296 297
297 bool DeferredImageDecoder::hotSpot(IntPoint& hotSpot) const 298 bool DeferredImageDecoder::hotSpot(IntPoint& hotSpot) const
298 { 299 {
299 // TODO: Implement. 300 // TODO: Implement.
300 return m_actualDecoder ? m_actualDecoder->hotSpot(hotSpot) : false; 301 return m_actualDecoder ? m_actualDecoder->hotSpot(hotSpot) : false;
301 } 302 }
302 303
303 } // namespace blink 304 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/graphics/DeferredImageDecoder.h ('k') | Source/platform/graphics/DeferredImageDecoderTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698