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

Side by Side Diff: Source/core/platform/graphics/chromium/test/MockImageDecoder.h

Issue 19838002: Reland change to enable deferred image decoding for animated GIFs (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: merved Created 7 years, 5 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
« no previous file with comments | « Source/core/platform/graphics/chromium/LazyDecodingPixelRef.cpp ('k') | no next file » | 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 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 17 matching lines...) Expand all
28 #include "core/platform/image-decoders/ImageDecoder.h" 28 #include "core/platform/image-decoders/ImageDecoder.h"
29 #include "wtf/PassOwnPtr.h" 29 #include "wtf/PassOwnPtr.h"
30 30
31 namespace WebCore { 31 namespace WebCore {
32 32
33 class MockImageDecoderClient { 33 class MockImageDecoderClient {
34 public: 34 public:
35 virtual void decoderBeingDestroyed() = 0; 35 virtual void decoderBeingDestroyed() = 0;
36 virtual void frameBufferRequested() = 0; 36 virtual void frameBufferRequested() = 0;
37 virtual ImageFrame::FrameStatus frameStatus() = 0; 37 virtual ImageFrame::FrameStatus frameStatus() = 0;
38 virtual size_t frameCount() = 0;
39 virtual int repetitionCount() const = 0;
40 virtual float frameDuration() const = 0;
38 }; 41 };
39 42
40 class MockImageDecoder : public ImageDecoder { 43 class MockImageDecoder : public ImageDecoder {
41 public: 44 public:
42 static PassOwnPtr<MockImageDecoder> create(MockImageDecoderClient* client) { return adoptPtr(new MockImageDecoder(client)); } 45 static PassOwnPtr<MockImageDecoder> create(MockImageDecoderClient* client) { return adoptPtr(new MockImageDecoder(client)); }
43 46
44 MockImageDecoder(MockImageDecoderClient* client) 47 MockImageDecoder(MockImageDecoderClient* client)
45 : ImageDecoder(ImageSource::AlphaPremultiplied, ImageSource::GammaAndCol orProfileApplied) 48 : ImageDecoder(ImageSource::AlphaPremultiplied, ImageSource::GammaAndCol orProfileApplied)
46 , m_frameBufferRequestCount(0)
47 , m_client(client) 49 , m_client(client)
48 { } 50 { }
49 51
50 ~MockImageDecoder() 52 ~MockImageDecoder()
51 { 53 {
52 m_client->decoderBeingDestroyed(); 54 m_client->decoderBeingDestroyed();
53 } 55 }
54 56
55 virtual bool setSize(unsigned width, unsigned height) 57 virtual bool setSize(unsigned width, unsigned height)
56 { 58 {
57 ImageDecoder::setSize(width, height); 59 ImageDecoder::setSize(width, height);
58 m_frameBufferCache.resize(1); 60 m_frameBufferCache.resize(1);
59 m_frameBufferCache[0].setSize(width, height); 61 m_frameBufferCache[0].setSize(width, height);
60 return true; 62 return true;
61 } 63 }
62 64
63 virtual void setFrameHasAlpha(bool hasAlpha) { m_frameBufferCache[0].setHasA lpha(hasAlpha); } 65 virtual void setFrameHasAlpha(bool hasAlpha) { m_frameBufferCache[0].setHasA lpha(hasAlpha); }
64 66
65 virtual String filenameExtension() const 67 virtual String filenameExtension() const
66 { 68 {
67 return "mock"; 69 return "mock";
68 } 70 }
69 71
72 virtual size_t frameCount()
73 {
74 return m_client->frameCount();
75 }
76
77 virtual int repetitionCount() const
78 {
79 return m_client->repetitionCount();
80 }
81
70 virtual ImageFrame* frameBufferAtIndex(size_t) 82 virtual ImageFrame* frameBufferAtIndex(size_t)
71 { 83 {
72 ++m_frameBufferRequestCount;
73 m_client->frameBufferRequested(); 84 m_client->frameBufferRequested();
74 85
75 m_frameBufferCache[0].setStatus(m_client->frameStatus()); 86 m_frameBufferCache[0].setStatus(m_client->frameStatus());
76 return &m_frameBufferCache[0]; 87 return &m_frameBufferCache[0];
77 } 88 }
78 89
79 int frameBufferRequestCount() const { return m_frameBufferRequestCount; } 90 virtual bool frameIsCompleteAtIndex(size_t) const
91 {
92 return m_client->frameStatus() == ImageFrame::FrameComplete;
93 }
94
95 virtual float frameDurationAtIndex(size_t) const
96 {
97 return m_client->frameDuration();
98 }
80 99
81 private: 100 private:
82 int m_frameBufferRequestCount;
83 MockImageDecoderClient* m_client; 101 MockImageDecoderClient* m_client;
84 }; 102 };
85 103
86 } // namespace WebCore 104 } // namespace WebCore
87 105
88 #endif // MockImageDecoder_h 106 #endif // MockImageDecoder_h
OLDNEW
« no previous file with comments | « Source/core/platform/graphics/chromium/LazyDecodingPixelRef.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698