| 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 "cc/render_surface_filters.h" | 7 #include "cc/render_surface_filters.h" |
| 8 | 8 |
| 9 #include "FloatSize.h" | 9 #include "FloatSize.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "third_party/skia/include/core/SkCanvas.h" | 11 #include "third_party/skia/include/core/SkCanvas.h" |
| 12 #include "third_party/skia/include/effects/SkBlurImageFilter.h" | 12 #include "third_party/skia/include/effects/SkBlurImageFilter.h" |
| 13 #include "third_party/skia/include/effects/SkColorMatrixFilter.h" | 13 #include "third_party/skia/include/effects/SkColorMatrixFilter.h" |
| 14 #include "third_party/skia/include/effects/SkMagnifierImageFilter.h" | 14 #include "third_party/skia/include/effects/SkMagnifierImageFilter.h" |
| 15 #include "third_party/skia/include/gpu/SkGpuDevice.h" | 15 #include "third_party/skia/include/gpu/SkGpuDevice.h" |
| 16 #include "third_party/skia/include/gpu/SkGrPixelRef.h" | 16 #include "third_party/skia/include/gpu/SkGrPixelRef.h" |
| 17 #include <public/WebFilterOperation.h> | 17 #include <public/WebFilterOperation.h> |
| 18 #include <public/WebFilterOperations.h> | 18 #include <public/WebFilterOperations.h> |
| 19 #include <public/WebGraphicsContext3D.h> | 19 #include <public/WebGraphicsContext3D.h> |
| 20 #include <wtf/MathExtras.h> | |
| 21 | 20 |
| 22 using namespace cc; | 21 namespace cc { |
| 23 | 22 |
| 24 namespace { | 23 namespace { |
| 25 | 24 |
| 26 void getBrightnessMatrix(float amount, SkScalar matrix[20]) | 25 void getBrightnessMatrix(float amount, SkScalar matrix[20]) |
| 27 { | 26 { |
| 28 memset(matrix, 0, 20 * sizeof(SkScalar)); | 27 memset(matrix, 0, 20 * sizeof(SkScalar)); |
| 29 // Old implementation, a la the draft spec, a straight-up scale, | 28 // Old implementation, a la the draft spec, a straight-up scale, |
| 30 // representing <feFunc[R|G|B] type="linear" slope="[amount]"> | 29 // representing <feFunc[R|G|B] type="linear" slope="[amount]"> |
| 31 // (See http://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html#bright
nessEquivalent) | 30 // (See http://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html#bright
nessEquivalent) |
| 32 // matrix[0] = matrix[6] = matrix[12] = amount; | 31 // matrix[0] = matrix[6] = matrix[12] = amount; |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 } | 301 } |
| 303 | 302 |
| 304 GrContext* m_grContext; | 303 GrContext* m_grContext; |
| 305 SkBitmap m_source; | 304 SkBitmap m_source; |
| 306 SkAutoTUnref<GrTexture> m_scratchTextures[2]; | 305 SkAutoTUnref<GrTexture> m_scratchTextures[2]; |
| 307 int m_currentTexture; | 306 int m_currentTexture; |
| 308 SkAutoTUnref<SkGpuDevice> m_device; | 307 SkAutoTUnref<SkGpuDevice> m_device; |
| 309 SkAutoTUnref<SkCanvas> m_canvas; | 308 SkAutoTUnref<SkCanvas> m_canvas; |
| 310 }; | 309 }; |
| 311 | 310 |
| 312 } | 311 } // namespace |
| 313 | |
| 314 namespace cc { | |
| 315 | 312 |
| 316 WebKit::WebFilterOperations RenderSurfaceFilters::optimize(const WebKit::WebFilt
erOperations& filters) | 313 WebKit::WebFilterOperations RenderSurfaceFilters::optimize(const WebKit::WebFilt
erOperations& filters) |
| 317 { | 314 { |
| 318 WebKit::WebFilterOperations newList; | 315 WebKit::WebFilterOperations newList; |
| 319 | 316 |
| 320 SkScalar accumulatedColorMatrix[20]; | 317 SkScalar accumulatedColorMatrix[20]; |
| 321 bool haveAccumulatedColorMatrix = false; | 318 bool haveAccumulatedColorMatrix = false; |
| 322 for (unsigned i = 0; i < filters.size(); ++i) { | 319 for (unsigned i = 0; i < filters.size(); ++i) { |
| 323 const WebKit::WebFilterOperation& op = filters.at(i); | 320 const WebKit::WebFilterOperation& op = filters.at(i); |
| 324 | 321 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 case WebKit::WebFilterOperation::FilterTypeOpacity: | 431 case WebKit::WebFilterOperation::FilterTypeOpacity: |
| 435 NOTREACHED(); | 432 NOTREACHED(); |
| 436 break; | 433 break; |
| 437 } | 434 } |
| 438 state.swap(); | 435 state.swap(); |
| 439 } | 436 } |
| 440 context3D->flush(); | 437 context3D->flush(); |
| 441 return state.source(); | 438 return state.source(); |
| 442 } | 439 } |
| 443 | 440 |
| 444 } | 441 } // namespace cc |
| OLD | NEW |