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

Side by Side Diff: WebCore/platform/graphics/chromium/ImageLayerChromium.cpp

Issue 10633016: Merge r120507 to chromium 1132 branch. (Closed) Base URL: svn://svn.chromium.org/webkit-readonly/branches/chromium/1132/Source/
Patch Set: Created 8 years, 6 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) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 { 76 {
77 return adoptPtr(new Texture(this, ManagedTexture::create(manager))); 77 return adoptPtr(new Texture(this, ManagedTexture::create(manager)));
78 } 78 }
79 79
80 virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat) 80 virtual SampledTexelFormat sampledTexelFormat(GC3Denum textureFormat)
81 { 81 {
82 return PlatformColor::sameComponentOrder(textureFormat) ? 82 return PlatformColor::sameComponentOrder(textureFormat) ?
83 LayerTextureUpdater::SampledTexelFormatRGBA : LayerTextureUpdate r::SampledTexelFormatBGRA; 83 LayerTextureUpdater::SampledTexelFormatRGBA : LayerTextureUpdate r::SampledTexelFormatBGRA;
84 } 84 }
85 85
86 virtual void updateLayerRect(const IntRect& contentRect, const IntSize& tile Size, int /* borderTexels */, float /* contentsScale */, IntRect* /* resultingOp aqueRect */)
87 {
88 m_texSubImage.setSubImageSize(tileSize);
89 }
90
91 virtual void updateTextureRect(GraphicsContext3D* context, TextureAllocator* allocator, ManagedTexture* texture, const IntRect& sourceRect, const IntRect& d estRect) 86 virtual void updateTextureRect(GraphicsContext3D* context, TextureAllocator* allocator, ManagedTexture* texture, const IntRect& sourceRect, const IntRect& d estRect)
92 { 87 {
93 texture->bindTexture(context, allocator); 88 texture->bindTexture(context, allocator);
94 89
95 // Source rect should never go outside the image pixels, even if this 90 // Source rect should never go outside the image pixels, even if this
96 // is requested because the texture extends outside the image. 91 // is requested because the texture extends outside the image.
97 IntRect clippedSourceRect = sourceRect; 92 IntRect clippedSourceRect = sourceRect;
98 clippedSourceRect.intersect(imageRect()); 93 IntRect imageRect = IntRect(0, 0, m_bitmap.width(), m_bitmap.height());
94 clippedSourceRect.intersect(imageRect);
99 95
100 IntRect clippedDestRect = destRect; 96 IntRect clippedDestRect = destRect;
101 clippedDestRect.move(clippedSourceRect.location() - sourceRect.location( )); 97 clippedDestRect.move(clippedSourceRect.location() - sourceRect.location( ));
102 clippedDestRect.setSize(clippedSourceRect.size()); 98 clippedDestRect.setSize(clippedSourceRect.size());
103 99
104 m_texSubImage.upload(m_image.pixels(), imageRect(), clippedSourceRect, c lippedDestRect, texture->format(), context); 100 SkAutoLockPixels lock(m_bitmap);
101 m_texSubImage.upload(static_cast<const uint8_t*>(m_bitmap.getPixels()), imageRect, clippedSourceRect, clippedDestRect, texture->format(), context);
105 } 102 }
106 103
107 void updateFromImage(NativeImagePtr nativeImage) 104 void setBitmap(const SkBitmap& bitmap)
108 { 105 {
109 m_image.updateFromImage(nativeImage); 106 m_bitmap = bitmap;
110 } 107 }
111 108
112 IntSize imageSize() const
113 {
114 return m_image.size();
115 }
116
117 private: 109 private:
118 explicit ImageLayerTextureUpdater(bool useMapTexSubImage) 110 explicit ImageLayerTextureUpdater(bool useMapTexSubImage)
119 : m_texSubImage(useMapTexSubImage) 111 : m_texSubImage(useMapTexSubImage)
120 { 112 {
121 } 113 }
122 114
123 IntRect imageRect() const 115 SkBitmap m_bitmap;
124 {
125 return IntRect(IntPoint::zero(), m_image.size());
126 }
127
128 PlatformImage m_image;
129 LayerTextureSubImage m_texSubImage; 116 LayerTextureSubImage m_texSubImage;
130 }; 117 };
131 118
132 PassRefPtr<ImageLayerChromium> ImageLayerChromium::create() 119 PassRefPtr<ImageLayerChromium> ImageLayerChromium::create()
133 { 120 {
134 return adoptRef(new ImageLayerChromium()); 121 return adoptRef(new ImageLayerChromium());
135 } 122 }
136 123
137 ImageLayerChromium::ImageLayerChromium() 124 ImageLayerChromium::ImageLayerChromium()
138 : TiledLayerChromium() 125 : TiledLayerChromium()
139 , m_imageForCurrentFrame(0)
140 { 126 {
141 } 127 }
142 128
143 ImageLayerChromium::~ImageLayerChromium() 129 ImageLayerChromium::~ImageLayerChromium()
144 { 130 {
145 } 131 }
146 132
147 void ImageLayerChromium::setContents(Image* contents) 133 void ImageLayerChromium::setBitmap(const SkBitmap& bitmap)
148 { 134 {
149 // setContents() currently gets called whenever there is any 135 // setBitmap() currently gets called whenever there is any
150 // style change that affects the layer even if that change doesn't 136 // style change that affects the layer even if that change doesn't
151 // affect the actual contents of the image (e.g. a CSS animation). 137 // affect the actual contents of the image (e.g. a CSS animation).
152 // With this check in place we avoid unecessary texture uploads. 138 // With this check in place we avoid unecessary texture uploads.
153 if ((m_contents == contents) && (m_contents->nativeImageForCurrentFrame() == m_imageForCurrentFrame)) 139 if (bitmap.pixelRef() && bitmap.pixelRef() == m_bitmap.pixelRef())
154 return; 140 return;
155 141
156 m_contents = contents; 142 m_bitmap = bitmap;
157 m_imageForCurrentFrame = m_contents->nativeImageForCurrentFrame();
158 setNeedsDisplay(); 143 setNeedsDisplay();
159 } 144 }
160 145
161 void ImageLayerChromium::update(CCTextureUpdater& updater, const CCOcclusionTrac ker* occlusion) 146 void ImageLayerChromium::update(CCTextureUpdater& updater, const CCOcclusionTrac ker* occlusion)
162 { 147 {
163 createTextureUpdaterIfNeeded(); 148 createTextureUpdaterIfNeeded();
164 if (m_needsDisplay) { 149 if (m_needsDisplay) {
165 m_textureUpdater->updateFromImage(m_contents->nativeImageForCurrentFrame ()); 150 m_textureUpdater->setBitmap(m_bitmap);
166 updateTileSizeAndTilingOption(); 151 updateTileSizeAndTilingOption();
167 invalidateRect(IntRect(IntPoint(), contentBounds())); 152 invalidateRect(IntRect(IntPoint(), contentBounds()));
168 m_needsDisplay = false; 153 m_needsDisplay = false;
169 } 154 }
170 155
171 updateLayerRect(updater, visibleLayerRect(), occlusion); 156 updateLayerRect(updater, visibleLayerRect(), occlusion);
172 } 157 }
173 158
174 void ImageLayerChromium::createTextureUpdaterIfNeeded() 159 void ImageLayerChromium::createTextureUpdaterIfNeeded()
175 { 160 {
176 if (m_textureUpdater) 161 if (m_textureUpdater)
177 return; 162 return;
178 163
179 m_textureUpdater = ImageLayerTextureUpdater::create(layerTreeHost()->layerRe ndererCapabilities().usingMapSub); 164 m_textureUpdater = ImageLayerTextureUpdater::create(layerTreeHost()->layerRe ndererCapabilities().usingMapSub);
180 GC3Denum textureFormat = layerTreeHost()->layerRendererCapabilities().bestTe xtureFormat; 165 GC3Denum textureFormat = layerTreeHost()->layerRendererCapabilities().bestTe xtureFormat;
181 setTextureFormat(textureFormat); 166 setTextureFormat(textureFormat);
182 setSampledTexelFormat(textureUpdater()->sampledTexelFormat(textureFormat)); 167 setSampledTexelFormat(textureUpdater()->sampledTexelFormat(textureFormat));
183 } 168 }
184 169
185 LayerTextureUpdater* ImageLayerChromium::textureUpdater() const 170 LayerTextureUpdater* ImageLayerChromium::textureUpdater() const
186 { 171 {
187 return m_textureUpdater.get(); 172 return m_textureUpdater.get();
188 } 173 }
189 174
190 IntSize ImageLayerChromium::contentBounds() const 175 IntSize ImageLayerChromium::contentBounds() const
191 { 176 {
192 if (!m_contents) 177 return IntSize(m_bitmap.width(), m_bitmap.height());
193 return IntSize();
194 return m_contents->size();
195 } 178 }
196 179
197 bool ImageLayerChromium::drawsContent() const 180 bool ImageLayerChromium::drawsContent() const
198 { 181 {
199 return m_contents && TiledLayerChromium::drawsContent(); 182 return !m_bitmap.isNull() && TiledLayerChromium::drawsContent();
200 } 183 }
201 184
202 bool ImageLayerChromium::needsContentsScale() const 185 bool ImageLayerChromium::needsContentsScale() const
203 { 186 {
204 // Contents scale is not need for image layer because this can be done in co mpositor more efficiently. 187 // Contents scale is not need for image layer because this can be done in co mpositor more efficiently.
205 return false; 188 return false;
206 } 189 }
207 190
208 } 191 }
209 #endif // USE(ACCELERATED_COMPOSITING) 192 #endif // USE(ACCELERATED_COMPOSITING)
OLDNEW
« no previous file with comments | « WebCore/platform/graphics/chromium/ImageLayerChromium.h ('k') | WebCore/platform/graphics/chromium/PlatformImage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698