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

Side by Side Diff: cc/CCRenderSurfaceFilters.cpp

Issue 10879109: Update libcc / bindings snapshot to WebKit r126830 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 | « cc/CCRenderSurface.cpp ('k') | cc/CCRenderSurfaceTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 6
7 #if USE(ACCELERATED_COMPOSITING) 7 #if USE(ACCELERATED_COMPOSITING)
8 8
9 #include "CCRenderSurfaceFilters.h" 9 #include "CCRenderSurfaceFilters.h"
10 10
11 #include "FloatSize.h" 11 #include "FloatSize.h"
12 #include "SkBlurImageFilter.h" 12 #include "SkBlurImageFilter.h"
13 #include "SkCanvas.h" 13 #include "SkCanvas.h"
14 #include "SkColorMatrixFilter.h" 14 #include "SkColorMatrixFilter.h"
15 #include "SkGpuDevice.h" 15 #include "SkGpuDevice.h"
16 #include "SkGrTexturePixelRef.h" 16 #include "SkGrPixelRef.h"
17 #include "SkMagnifierImageFilter.h" 17 #include "SkMagnifierImageFilter.h"
18 #include <public/WebFilterOperation.h> 18 #include <public/WebFilterOperation.h>
19 #include <public/WebFilterOperations.h> 19 #include <public/WebFilterOperations.h>
20 #include <public/WebGraphicsContext3D.h> 20 #include <public/WebGraphicsContext3D.h>
21 #include <wtf/MathExtras.h> 21 #include <wtf/MathExtras.h>
22 22
23 namespace { 23 namespace {
24 24
25 void getBrightnessMatrix(float amount, SkScalar matrix[20]) 25 void getBrightnessMatrix(float amount, SkScalar matrix[20])
26 { 26 {
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 class FilterBufferState { 237 class FilterBufferState {
238 public: 238 public:
239 FilterBufferState(GrContext* grContext, const WebCore::FloatSize& size, unsi gned textureId) 239 FilterBufferState(GrContext* grContext, const WebCore::FloatSize& size, unsi gned textureId)
240 : m_grContext(grContext) 240 : m_grContext(grContext)
241 , m_currentTexture(0) 241 , m_currentTexture(0)
242 { 242 {
243 // Wrap the source texture in a Ganesh platform texture. 243 // Wrap the source texture in a Ganesh platform texture.
244 GrPlatformTextureDesc platformTextureDescription; 244 GrPlatformTextureDesc platformTextureDescription;
245 platformTextureDescription.fWidth = size.width(); 245 platformTextureDescription.fWidth = size.width();
246 platformTextureDescription.fHeight = size.height(); 246 platformTextureDescription.fHeight = size.height();
247 platformTextureDescription.fConfig = kSkia8888_PM_GrPixelConfig; 247 platformTextureDescription.fConfig = kSkia8888_GrPixelConfig;
248 platformTextureDescription.fTextureHandle = textureId; 248 platformTextureDescription.fTextureHandle = textureId;
249 SkAutoTUnref<GrTexture> texture(grContext->createPlatformTexture(platfor mTextureDescription)); 249 SkAutoTUnref<GrTexture> texture(grContext->createPlatformTexture(platfor mTextureDescription));
250 // Place the platform texture inside an SkBitmap. 250 // Place the platform texture inside an SkBitmap.
251 m_source.setConfig(SkBitmap::kARGB_8888_Config, size.width(), size.heigh t()); 251 m_source.setConfig(SkBitmap::kARGB_8888_Config, size.width(), size.heigh t());
252 m_source.setPixelRef(new SkGrTexturePixelRef(texture.get()))->unref(); 252 m_source.setPixelRef(new SkGrPixelRef(texture.get()))->unref();
253 } 253 }
254 254
255 ~FilterBufferState() { } 255 ~FilterBufferState() { }
256 256
257 bool init(int filterCount) 257 bool init(int filterCount)
258 { 258 {
259 int scratchCount = std::min(2, filterCount); 259 int scratchCount = std::min(2, filterCount);
260 GrTextureDesc desc; 260 GrTextureDesc desc;
261 desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagB it; 261 desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagB it;
262 desc.fSampleCnt = 0; 262 desc.fSampleCnt = 0;
263 desc.fWidth = m_source.width(); 263 desc.fWidth = m_source.width();
264 desc.fHeight = m_source.height(); 264 desc.fHeight = m_source.height();
265 desc.fConfig = kSkia8888_PM_GrPixelConfig; 265 desc.fConfig = kSkia8888_GrPixelConfig;
266 for (int i = 0; i < scratchCount; ++i) { 266 for (int i = 0; i < scratchCount; ++i) {
267 GrAutoScratchTexture scratchTexture(m_grContext, desc, GrContext::kE xact_ScratchTexMatch); 267 GrAutoScratchTexture scratchTexture(m_grContext, desc, GrContext::kE xact_ScratchTexMatch);
268 m_scratchTextures[i].reset(scratchTexture.detach()); 268 m_scratchTextures[i].reset(scratchTexture.detach());
269 if (!m_scratchTextures[i].get()) 269 if (!m_scratchTextures[i].get())
270 return false; 270 return false;
271 } 271 }
272 return true; 272 return true;
273 } 273 }
274 274
275 SkCanvas* canvas() 275 SkCanvas* canvas()
276 { 276 {
277 if (!m_canvas.get()) 277 if (!m_canvas.get())
278 createCanvas(); 278 createCanvas();
279 return m_canvas.get(); 279 return m_canvas.get();
280 } 280 }
281 281
282 const SkBitmap& source() { return m_source; } 282 const SkBitmap& source() { return m_source; }
283 283
284 void swap() 284 void swap()
285 { 285 {
286 m_canvas->flush(); 286 m_canvas->flush();
287 m_canvas.reset(0); 287 m_canvas.reset(0);
288 m_device.reset(0); 288 m_device.reset(0);
289 289
290 m_source.setPixelRef(new SkGrTexturePixelRef(m_scratchTextures[m_current Texture].get()))->unref(); 290 m_source.setPixelRef(new SkGrPixelRef(m_scratchTextures[m_currentTexture ].get()))->unref();
291 m_currentTexture = 1 - m_currentTexture; 291 m_currentTexture = 1 - m_currentTexture;
292 } 292 }
293 293
294 private: 294 private:
295 void createCanvas() 295 void createCanvas()
296 { 296 {
297 ASSERT(m_scratchTextures[m_currentTexture].get()); 297 ASSERT(m_scratchTextures[m_currentTexture].get());
298 m_device.reset(new SkGpuDevice(m_grContext, m_scratchTextures[m_currentT exture].get())); 298 m_device.reset(new SkGpuDevice(m_grContext, m_scratchTextures[m_currentT exture].get()));
299 m_canvas.reset(new SkCanvas(m_device.get())); 299 m_canvas.reset(new SkCanvas(m_device.get()));
300 m_canvas->clear(0x0); 300 m_canvas->clear(0x0);
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 break; 434 break;
435 } 435 }
436 state.swap(); 436 state.swap();
437 } 437 }
438 context3D->flush(); 438 context3D->flush();
439 return state.source(); 439 return state.source();
440 } 440 }
441 441
442 } 442 }
443 #endif // USE(ACCELERATED_COMPOSITING) 443 #endif // USE(ACCELERATED_COMPOSITING)
OLDNEW
« no previous file with comments | « cc/CCRenderSurface.cpp ('k') | cc/CCRenderSurfaceTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698