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 #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 "SkGrPixelRef.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 using namespace cc; |
| 24 |
23 namespace { | 25 namespace { |
24 | 26 |
25 void getBrightnessMatrix(float amount, SkScalar matrix[20]) | 27 void getBrightnessMatrix(float amount, SkScalar matrix[20]) |
26 { | 28 { |
27 memset(matrix, 0, 20 * sizeof(SkScalar)); | 29 memset(matrix, 0, 20 * sizeof(SkScalar)); |
28 // Old implementation, a la the draft spec, a straight-up scale, | 30 // Old implementation, a la the draft spec, a straight-up scale, |
29 // representing <feFunc[R|G|B] type="linear" slope="[amount]"> | 31 // representing <feFunc[R|G|B] type="linear" slope="[amount]"> |
30 // (See http://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html#bright
nessEquivalent) | 32 // (See http://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html#bright
nessEquivalent) |
31 // matrix[0] = matrix[6] = matrix[12] = amount; | 33 // matrix[0] = matrix[6] = matrix[12] = amount; |
32 // matrix[18] = 1; | 34 // matrix[18] = 1; |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 memcpy(matrix, op.matrix(), sizeof(SkScalar[20])); | 231 memcpy(matrix, op.matrix(), sizeof(SkScalar[20])); |
230 return true; | 232 return true; |
231 } | 233 } |
232 default: | 234 default: |
233 return false; | 235 return false; |
234 } | 236 } |
235 } | 237 } |
236 | 238 |
237 class FilterBufferState { | 239 class FilterBufferState { |
238 public: | 240 public: |
239 FilterBufferState(GrContext* grContext, const WebCore::FloatSize& size, unsi
gned textureId) | 241 FilterBufferState(GrContext* grContext, const FloatSize& size, unsigned text
ureId) |
240 : m_grContext(grContext) | 242 : m_grContext(grContext) |
241 , m_currentTexture(0) | 243 , m_currentTexture(0) |
242 { | 244 { |
243 // Wrap the source texture in a Ganesh platform texture. | 245 // Wrap the source texture in a Ganesh platform texture. |
244 GrPlatformTextureDesc platformTextureDescription; | 246 GrPlatformTextureDesc platformTextureDescription; |
245 platformTextureDescription.fWidth = size.width(); | 247 platformTextureDescription.fWidth = size.width(); |
246 platformTextureDescription.fHeight = size.height(); | 248 platformTextureDescription.fHeight = size.height(); |
247 platformTextureDescription.fConfig = kSkia8888_GrPixelConfig; | 249 platformTextureDescription.fConfig = kSkia8888_GrPixelConfig; |
248 platformTextureDescription.fTextureHandle = textureId; | 250 platformTextureDescription.fTextureHandle = textureId; |
249 SkAutoTUnref<GrTexture> texture(grContext->createPlatformTexture(platfor
mTextureDescription)); | 251 SkAutoTUnref<GrTexture> texture(grContext->createPlatformTexture(platfor
mTextureDescription)); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 GrContext* m_grContext; | 305 GrContext* m_grContext; |
304 SkBitmap m_source; | 306 SkBitmap m_source; |
305 SkAutoTUnref<GrTexture> m_scratchTextures[2]; | 307 SkAutoTUnref<GrTexture> m_scratchTextures[2]; |
306 int m_currentTexture; | 308 int m_currentTexture; |
307 SkAutoTUnref<SkGpuDevice> m_device; | 309 SkAutoTUnref<SkGpuDevice> m_device; |
308 SkAutoTUnref<SkCanvas> m_canvas; | 310 SkAutoTUnref<SkCanvas> m_canvas; |
309 }; | 311 }; |
310 | 312 |
311 } | 313 } |
312 | 314 |
313 namespace WebCore { | 315 namespace cc { |
314 | 316 |
315 WebKit::WebFilterOperations CCRenderSurfaceFilters::optimize(const WebKit::WebFi
lterOperations& filters) | 317 WebKit::WebFilterOperations CCRenderSurfaceFilters::optimize(const WebKit::WebFi
lterOperations& filters) |
316 { | 318 { |
317 WebKit::WebFilterOperations newList; | 319 WebKit::WebFilterOperations newList; |
318 | 320 |
319 SkScalar accumulatedColorMatrix[20]; | 321 SkScalar accumulatedColorMatrix[20]; |
320 bool haveAccumulatedColorMatrix = false; | 322 bool haveAccumulatedColorMatrix = false; |
321 for (unsigned i = 0; i < filters.size(); ++i) { | 323 for (unsigned i = 0; i < filters.size(); ++i) { |
322 const WebKit::WebFilterOperation& op = filters.at(i); | 324 const WebKit::WebFilterOperation& op = filters.at(i); |
323 | 325 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 break; | 437 break; |
436 } | 438 } |
437 state.swap(); | 439 state.swap(); |
438 } | 440 } |
439 context3D->flush(); | 441 context3D->flush(); |
440 return state.source(); | 442 return state.source(); |
441 } | 443 } |
442 | 444 |
443 } | 445 } |
444 #endif // USE(ACCELERATED_COMPOSITING) | 446 #endif // USE(ACCELERATED_COMPOSITING) |
OLD | NEW |