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

Side by Side Diff: Source/core/platform/graphics/chromium/LazyDecodingPixelRef.cpp

Issue 26679003: Move platform/graphics/chromium/* to platform/graphics/ (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rename fix Created 7 years, 1 month 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
(Empty)
1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26 #include "config.h"
27 #include "core/platform/graphics/chromium/LazyDecodingPixelRef.h"
28
29 #include "SkData.h"
30 #include "core/platform/graphics/chromium/ImageDecodingStore.h"
31 #include "core/platform/graphics/chromium/ImageFrameGenerator.h"
32 #include "platform/TraceEvent.h"
33
34 namespace WebCore {
35
36 LazyDecodingPixelRef::LazyDecodingPixelRef(PassRefPtr<ImageFrameGenerator> frame Generator, size_t index)
37 : m_frameGenerator(frameGenerator)
38 , m_frameIndex(index)
39 , m_lockedImageResource(0)
40 , m_objectTracker(this)
41 {
42 }
43
44 LazyDecodingPixelRef::~LazyDecodingPixelRef()
45 {
46 }
47
48 SkData* LazyDecodingPixelRef::onRefEncodedData()
49 {
50 // If the image has been clipped or scaled, do not return the original encod ed data, since
51 // on playback it will not be known how the clipping/scaling was done.
52 RefPtr<SharedBuffer> buffer = 0;
53 bool allDataReceived = false;
54 m_frameGenerator->copyData(&buffer, &allDataReceived);
55 if (buffer && allDataReceived) {
56 SkData* skdata = SkData::NewWithCopy((void*)buffer->data(), buffer->size ());
57 return skdata;
58 }
59 return 0;
60 }
61
62 void* LazyDecodingPixelRef::onLockPixels(SkColorTable**)
63 {
64 TRACE_EVENT_ASYNC_BEGIN0("webkit", "LazyDecodingPixelRef::lockPixels", this) ;
65
66 ASSERT(!m_lockedImageResource);
67
68 SkISize size = m_frameGenerator->getFullSize();
69 if (!ImageDecodingStore::instance()->lockCache(m_frameGenerator.get(), size, m_frameIndex, &m_lockedImageResource))
70 m_lockedImageResource = 0;
71
72 // Use ImageFrameGenerator to generate the image. It will lock the cache
73 // entry for us.
74 if (!m_lockedImageResource)
75 m_lockedImageResource = m_frameGenerator->decodeAndScale(size, m_frameIn dex);
76
77 if (!m_lockedImageResource)
78 return 0;
79
80 ASSERT(!m_lockedImageResource->bitmap().isNull());
81 ASSERT(m_lockedImageResource->scaledSize() == size);
82 return m_lockedImageResource->bitmap().getAddr(0, 0);
83 }
84
85 void LazyDecodingPixelRef::onUnlockPixels()
86 {
87 if (m_lockedImageResource) {
88 ImageDecodingStore::instance()->unlockCache(m_frameGenerator.get(), m_lo ckedImageResource);
89 m_lockedImageResource = 0;
90 }
91
92 TRACE_EVENT_ASYNC_END0("webkit", "LazyDecodingPixelRef::lockPixels", this);
93 }
94
95 bool LazyDecodingPixelRef::onLockPixelsAreWritable() const
96 {
97 return false;
98 }
99
100 bool LazyDecodingPixelRef::MaybeDecoded()
101 {
102 return ImageDecodingStore::instance()->isCached(m_frameGenerator.get(), m_fr ameGenerator->getFullSize(), m_frameIndex);
103 }
104
105 bool LazyDecodingPixelRef::PrepareToDecode(const LazyPixelRef::PrepareParams& pa rams)
106 {
107 ASSERT(false);
108 return false;
109 }
110
111 void LazyDecodingPixelRef::Decode()
112 {
113 lockPixels();
114 unlockPixels();
115 }
116
117
118 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698