OLD | NEW |
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 #include "CCRenderSurfaceFilters.h" | 7 #include "CCRenderSurfaceFilters.h" |
8 | 8 |
9 #include "FloatSize.h" | 9 #include "FloatSize.h" |
10 #include "third_party/skia/include/core/SkCanvas.h" | 10 #include "third_party/skia/include/core/SkCanvas.h" |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 SkAutoTUnref<GrTexture> m_scratchTextures[2]; | 305 SkAutoTUnref<GrTexture> m_scratchTextures[2]; |
306 int m_currentTexture; | 306 int m_currentTexture; |
307 SkAutoTUnref<SkGpuDevice> m_device; | 307 SkAutoTUnref<SkGpuDevice> m_device; |
308 SkAutoTUnref<SkCanvas> m_canvas; | 308 SkAutoTUnref<SkCanvas> m_canvas; |
309 }; | 309 }; |
310 | 310 |
311 } | 311 } |
312 | 312 |
313 namespace cc { | 313 namespace cc { |
314 | 314 |
315 WebKit::WebFilterOperations CCRenderSurfaceFilters::optimize(const WebKit::WebFi
lterOperations& filters) | 315 WebKit::WebFilterOperations RenderSurfaceFilters::optimize(const WebKit::WebFilt
erOperations& filters) |
316 { | 316 { |
317 WebKit::WebFilterOperations newList; | 317 WebKit::WebFilterOperations newList; |
318 | 318 |
319 SkScalar accumulatedColorMatrix[20]; | 319 SkScalar accumulatedColorMatrix[20]; |
320 bool haveAccumulatedColorMatrix = false; | 320 bool haveAccumulatedColorMatrix = false; |
321 for (unsigned i = 0; i < filters.size(); ++i) { | 321 for (unsigned i = 0; i < filters.size(); ++i) { |
322 const WebKit::WebFilterOperation& op = filters.at(i); | 322 const WebKit::WebFilterOperation& op = filters.at(i); |
323 | 323 |
324 // If the filter is a color matrix, we may be able to combine it with | 324 // If the filter is a color matrix, we may be able to combine it with |
325 // following filter(s) that also are color matrices. | 325 // following filter(s) that also are color matrices. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 case WebKit::WebFilterOperation::FilterTypeOpacity: | 360 case WebKit::WebFilterOperation::FilterTypeOpacity: |
361 case WebKit::WebFilterOperation::FilterTypeColorMatrix: | 361 case WebKit::WebFilterOperation::FilterTypeColorMatrix: |
362 break; | 362 break; |
363 } | 363 } |
364 } | 364 } |
365 if (haveAccumulatedColorMatrix) | 365 if (haveAccumulatedColorMatrix) |
366 newList.append(WebKit::WebFilterOperation::createColorMatrixFilter(accum
ulatedColorMatrix)); | 366 newList.append(WebKit::WebFilterOperation::createColorMatrixFilter(accum
ulatedColorMatrix)); |
367 return newList; | 367 return newList; |
368 } | 368 } |
369 | 369 |
370 SkBitmap CCRenderSurfaceFilters::apply(const WebKit::WebFilterOperations& filter
s, unsigned textureId, const FloatSize& size, WebKit::WebGraphicsContext3D* cont
ext3D, GrContext* grContext) | 370 SkBitmap RenderSurfaceFilters::apply(const WebKit::WebFilterOperations& filters,
unsigned textureId, const FloatSize& size, WebKit::WebGraphicsContext3D* contex
t3D, GrContext* grContext) |
371 { | 371 { |
372 if (!context3D || !grContext) | 372 if (!context3D || !grContext) |
373 return SkBitmap(); | 373 return SkBitmap(); |
374 | 374 |
375 WebKit::WebFilterOperations optimizedFilters = optimize(filters); | 375 WebKit::WebFilterOperations optimizedFilters = optimize(filters); |
376 FilterBufferState state(grContext, size, textureId); | 376 FilterBufferState state(grContext, size, textureId); |
377 if (!state.init(optimizedFilters.size())) | 377 if (!state.init(optimizedFilters.size())) |
378 return SkBitmap(); | 378 return SkBitmap(); |
379 | 379 |
380 for (unsigned i = 0; i < optimizedFilters.size(); ++i) { | 380 for (unsigned i = 0; i < optimizedFilters.size(); ++i) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 ASSERT_NOT_REACHED(); | 434 ASSERT_NOT_REACHED(); |
435 break; | 435 break; |
436 } | 436 } |
437 state.swap(); | 437 state.swap(); |
438 } | 438 } |
439 context3D->flush(); | 439 context3D->flush(); |
440 return state.source(); | 440 return state.source(); |
441 } | 441 } |
442 | 442 |
443 } | 443 } |
OLD | NEW |