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

Side by Side Diff: sky/engine/core/fetch/ImageResource.h

Issue 1223793006: Delete sky/engine/core/fetch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 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
« no previous file with comments | « sky/engine/core/fetch/FontResource.cpp ('k') | sky/engine/core/fetch/ImageResource.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de)
3 Copyright (C) 2001 Dirk Mueller <mueller@kde.org>
4 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
5 Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
16
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
21 */
22
23 #ifndef SKY_ENGINE_CORE_FETCH_IMAGERESOURCE_H_
24 #define SKY_ENGINE_CORE_FETCH_IMAGERESOURCE_H_
25
26 #include "sky/engine/core/fetch/ResourcePtr.h"
27 #include "sky/engine/platform/geometry/IntRect.h"
28 #include "sky/engine/platform/geometry/IntSizeHash.h"
29 #include "sky/engine/platform/geometry/LayoutSize.h"
30 #include "sky/engine/platform/graphics/ImageObserver.h"
31 #include "sky/engine/wtf/HashMap.h"
32
33 namespace blink {
34
35 class ImageResourceClient;
36 class ResourceFetcher;
37 class FloatSize;
38 class Length;
39 class MemoryCache;
40 class RenderObject;
41
42 class ImageResource final : public Resource, public ImageObserver {
43 friend class MemoryCache;
44
45 public:
46 typedef ImageResourceClient ClientType;
47
48 ImageResource(const ResourceRequest&);
49 ImageResource(blink::Image*);
50 // Exposed for testing
51 ImageResource(const ResourceRequest&, blink::Image*);
52 virtual ~ImageResource();
53
54 virtual void load(ResourceFetcher*, const ResourceLoaderOptions&) override;
55
56 blink::Image* image(); // Returns the nullImage() if the image is not availa ble yet.
57 blink::Image* imageForRenderer(const RenderObject*); // Returns the nullImag e() if the image is not available yet.
58 bool hasImage() const { return m_image.get(); }
59 bool currentFrameKnownToBeOpaque(const RenderObject*); // Side effect: ensur es decoded image is in cache, therefore should only be called when about to draw the image.
60
61 bool canRender(const RenderObject& renderer) { return !errorOccurred() && !i mageSizeForRenderer(&renderer).isEmpty(); }
62
63 void setContainerSizeForRenderer(const ImageResourceClient*, const IntSize&) ;
64 bool usesImageContainerSize() const;
65 bool imageHasRelativeWidth() const;
66 bool imageHasRelativeHeight() const;
67 // The device pixel ratio we got from the server for this image, or 1.0.
68 float devicePixelRatioHeaderValue() const { return m_devicePixelRatioHeaderV alue; }
69 bool hasDevicePixelRatioHeaderValue() const { return m_hasDevicePixelRatioHe aderValue; }
70
71 enum SizeType {
72 NormalSize, // Report the size of the image associated with a certain re nderer
73 IntrinsicSize // Report the intrinsic size, i.e. ignore whatever has bee n set extrinsically.
74 };
75 LayoutSize imageSizeForRenderer(const RenderObject*, SizeType = NormalSize); // returns the size of the complete image.
76 void computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHei ght, FloatSize& intrinsicRatio);
77
78 virtual void didAddClient(ResourceClient*) override;
79 virtual void didRemoveClient(ResourceClient*) override;
80
81 virtual void allClientsRemoved() override;
82
83 virtual void appendData(const char*, int) override;
84 virtual void error(Resource::Status) override;
85 virtual void responseReceived(const ResourceResponse&) override;
86 virtual void finishOnePart() override;
87
88 // For compatibility, images keep loading even if there are HTTP errors.
89 virtual bool shouldIgnoreHTTPStatusCodeErrors() const override { return true ; }
90
91 virtual bool isImage() const override { return true; }
92 virtual bool stillNeedsLoad() const override { return !errorOccurred() && st atus() == Unknown && !isLoading(); }
93
94 // ImageObserver
95 virtual void decodedSizeChanged(const blink::Image*, int delta) override;
96 virtual void didDraw(const blink::Image*) override;
97
98 virtual bool shouldPauseAnimation(const blink::Image*) override;
99 virtual void animationAdvanced(const blink::Image*) override;
100 virtual void changedInRect(const blink::Image*, const IntRect&) override;
101
102 protected:
103 virtual bool isSafeToUnlock() const override;
104 virtual void destroyDecodedDataIfPossible() override;
105
106 private:
107 void clear();
108
109 void setCustomAcceptHeader();
110 void createImage();
111 void updateImage(bool allDataReceived);
112 void clearImage();
113 // If not null, changeRect is the changed part of the image.
114 void notifyObservers(const IntRect* changeRect = 0);
115
116 virtual void switchClientsToRevalidatedResource() override;
117
118 typedef HashMap<const ImageResourceClient*, IntSize> ContainerSizeRequests;
119 ContainerSizeRequests m_pendingContainerSizeRequests;
120 float m_devicePixelRatioHeaderValue;
121
122 RefPtr<blink::Image> m_image;
123 bool m_loadingMultipartContent;
124 bool m_hasDevicePixelRatioHeaderValue;
125 };
126
127 DEFINE_RESOURCE_TYPE_CASTS(Image);
128
129 }
130
131 #endif // SKY_ENGINE_CORE_FETCH_IMAGERESOURCE_H_
OLDNEW
« no previous file with comments | « sky/engine/core/fetch/FontResource.cpp ('k') | sky/engine/core/fetch/ImageResource.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698