| 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 "cc/render_surface_filters.h" | 5 #include "cc/render_surface_filters.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "skia/ext/refptr.h" | 8 #include "skia/ext/refptr.h" |
| 9 #include "third_party/WebKit/Source/Platform/chromium/public/WebFilterOperation.
h" | 9 #include "third_party/WebKit/Source/Platform/chromium/public/WebFilterOperation.
h" |
| 10 #include "third_party/WebKit/Source/Platform/chromium/public/WebFilterOperations
.h" | 10 #include "third_party/WebKit/Source/Platform/chromium/public/WebFilterOperations
.h" |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); | 417 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); |
| 418 canvas->saveLayer(NULL, &paint); | 418 canvas->saveLayer(NULL, &paint); |
| 419 canvas->drawBitmap(state.Source(), | 419 canvas->drawBitmap(state.Source(), |
| 420 op.dropShadowOffset().x, | 420 op.dropShadowOffset().x, |
| 421 -op.dropShadowOffset().y); | 421 -op.dropShadowOffset().y); |
| 422 canvas->restore(); | 422 canvas->restore(); |
| 423 canvas->drawBitmap(state.Source(), 0, 0); | 423 canvas->drawBitmap(state.Source(), 0, 0); |
| 424 break; | 424 break; |
| 425 } | 425 } |
| 426 case WebKit::WebFilterOperation::FilterTypeZoom: { | 426 case WebKit::WebFilterOperation::FilterTypeZoom: { |
| 427 #ifdef NEW_ZOOM_FILTER // TODO(danakj): Remove this when WebKit rolls. |
| 427 SkPaint paint; | 428 SkPaint paint; |
| 429 int width = state.Source().width(); |
| 430 int height = state.Source().height(); |
| 428 skia::RefPtr<SkImageFilter> zoom_filter = skia::AdoptRef( | 431 skia::RefPtr<SkImageFilter> zoom_filter = skia::AdoptRef( |
| 429 new SkMagnifierImageFilter( | 432 new SkMagnifierImageFilter( |
| 430 SkRect::MakeXYWH(op.zoomRect().x, | 433 SkRect::MakeXYWH( |
| 431 op.zoomRect().y, | 434 (width - (width / op.amount())) / 2.f, |
| 432 op.zoomRect().width, | 435 (height - (height / op.amount())) / 2.f, |
| 433 op.zoomRect().height), | 436 width / op.amount(), |
| 434 op.amount())); | 437 height / op.amount()), |
| 438 op.zoomInset())); |
| 435 paint.setImageFilter(zoom_filter.get()); | 439 paint.setImageFilter(zoom_filter.get()); |
| 436 canvas->saveLayer(NULL, &paint); | 440 canvas->saveLayer(NULL, &paint); |
| 437 canvas->drawBitmap(state.Source(), 0, 0); | 441 canvas->drawBitmap(state.Source(), 0, 0); |
| 438 canvas->restore(); | 442 canvas->restore(); |
| 443 #endif |
| 439 break; | 444 break; |
| 440 } | 445 } |
| 441 case WebKit::WebFilterOperation::FilterTypeBrightness: | 446 case WebKit::WebFilterOperation::FilterTypeBrightness: |
| 442 case WebKit::WebFilterOperation::FilterTypeSaturatingBrightness: | 447 case WebKit::WebFilterOperation::FilterTypeSaturatingBrightness: |
| 443 case WebKit::WebFilterOperation::FilterTypeContrast: | 448 case WebKit::WebFilterOperation::FilterTypeContrast: |
| 444 case WebKit::WebFilterOperation::FilterTypeGrayscale: | 449 case WebKit::WebFilterOperation::FilterTypeGrayscale: |
| 445 case WebKit::WebFilterOperation::FilterTypeSepia: | 450 case WebKit::WebFilterOperation::FilterTypeSepia: |
| 446 case WebKit::WebFilterOperation::FilterTypeSaturate: | 451 case WebKit::WebFilterOperation::FilterTypeSaturate: |
| 447 case WebKit::WebFilterOperation::FilterTypeHueRotate: | 452 case WebKit::WebFilterOperation::FilterTypeHueRotate: |
| 448 case WebKit::WebFilterOperation::FilterTypeInvert: | 453 case WebKit::WebFilterOperation::FilterTypeInvert: |
| 449 case WebKit::WebFilterOperation::FilterTypeOpacity: | 454 case WebKit::WebFilterOperation::FilterTypeOpacity: |
| 450 NOTREACHED(); | 455 NOTREACHED(); |
| 451 break; | 456 break; |
| 452 } | 457 } |
| 453 state.Swap(); | 458 state.Swap(); |
| 454 } | 459 } |
| 455 return state.Source(); | 460 return state.Source(); |
| 456 } | 461 } |
| 457 | 462 |
| 458 } // namespace cc | 463 } // namespace cc |
| OLD | NEW |