Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ui/gfx/canvas_skia.h" | 5 #include "ui/gfx/canvas_skia.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 102 SkIntToScalar(layer_bounds.y()), | 102 SkIntToScalar(layer_bounds.y()), |
| 103 SkIntToScalar(layer_bounds.right()), | 103 SkIntToScalar(layer_bounds.right()), |
| 104 SkIntToScalar(layer_bounds.bottom())); | 104 SkIntToScalar(layer_bounds.bottom())); |
| 105 canvas_->saveLayerAlpha(&bounds, alpha); | 105 canvas_->saveLayerAlpha(&bounds, alpha); |
| 106 } | 106 } |
| 107 | 107 |
| 108 void CanvasSkia::Restore() { | 108 void CanvasSkia::Restore() { |
| 109 canvas_->restore(); | 109 canvas_->restore(); |
| 110 } | 110 } |
| 111 | 111 |
| 112 bool CanvasSkia::ClipRectInt(int x, int y, int w, int h) { | 112 bool CanvasSkia::ClipRectInt(const gfx::Rect& rect) { |
| 113 SkRect new_clip; | 113 SkRect new_clip; |
|
Peter Kasting
2011/10/25 20:24:47
Nit: Simpler:
return canvas_->clipRect(gfx::RectT
tfarina
2011/10/25 23:52:41
Done.
| |
| 114 new_clip.set(SkIntToScalar(x), SkIntToScalar(y), | 114 new_clip.set(SkIntToScalar(rect.x()), |
| 115 SkIntToScalar(x + w), SkIntToScalar(y + h)); | 115 SkIntToScalar(rect.y()), |
| 116 SkIntToScalar(rect.x() + rect.width()), | |
| 117 SkIntToScalar(rect.y() + rect.height())); | |
| 116 return canvas_->clipRect(new_clip); | 118 return canvas_->clipRect(new_clip); |
| 117 } | 119 } |
| 118 | 120 |
| 119 void CanvasSkia::TranslateInt(int x, int y) { | 121 void CanvasSkia::TranslateInt(int x, int y) { |
| 120 canvas_->translate(SkIntToScalar(x), SkIntToScalar(y)); | 122 canvas_->translate(SkIntToScalar(x), SkIntToScalar(y)); |
| 121 } | 123 } |
| 122 | 124 |
| 123 void CanvasSkia::ScaleInt(int x, int y) { | 125 void CanvasSkia::ScaleInt(int x, int y) { |
| 124 canvas_->scale(SkIntToScalar(x), SkIntToScalar(y)); | 126 canvas_->scale(SkIntToScalar(x), SkIntToScalar(y)); |
| 125 } | 127 } |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 329 SkShader::kRepeat_TileMode); | 331 SkShader::kRepeat_TileMode); |
| 330 paint.setShader(shader); | 332 paint.setShader(shader); |
| 331 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); | 333 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode); |
| 332 | 334 |
| 333 // CreateBitmapShader returns a Shader with a reference count of one, we | 335 // CreateBitmapShader returns a Shader with a reference count of one, we |
| 334 // need to unref after paint takes ownership of the shader. | 336 // need to unref after paint takes ownership of the shader. |
| 335 shader->unref(); | 337 shader->unref(); |
| 336 canvas_->save(); | 338 canvas_->save(); |
| 337 canvas_->translate(SkIntToScalar(dest_x - src_x), | 339 canvas_->translate(SkIntToScalar(dest_x - src_x), |
| 338 SkIntToScalar(dest_y - src_y)); | 340 SkIntToScalar(dest_y - src_y)); |
| 339 ClipRectInt(src_x, src_y, w, h); | 341 ClipRectInt(gfx::Rect(src_x, src_y, w, h)); |
| 340 canvas_->drawPaint(paint); | 342 canvas_->drawPaint(paint); |
| 341 canvas_->restore(); | 343 canvas_->restore(); |
| 342 } | 344 } |
| 343 | 345 |
| 344 gfx::NativeDrawingContext CanvasSkia::BeginPlatformPaint() { | 346 gfx::NativeDrawingContext CanvasSkia::BeginPlatformPaint() { |
| 345 return skia::BeginPlatformPaint(canvas_); | 347 return skia::BeginPlatformPaint(canvas_); |
| 346 } | 348 } |
| 347 | 349 |
| 348 void CanvasSkia::EndPlatformPaint() { | 350 void CanvasSkia::EndPlatformPaint() { |
| 349 skia::EndPlatformPaint(canvas_); | 351 skia::EndPlatformPaint(canvas_); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 415 | 417 |
| 416 CanvasPaint* CanvasPaint::CreateCanvasPaint(gfx::NativeView view) { | 418 CanvasPaint* CanvasPaint::CreateCanvasPaint(gfx::NativeView view) { |
| 417 #if defined(OS_WIN) && !defined(USE_AURA) | 419 #if defined(OS_WIN) && !defined(USE_AURA) |
| 418 return new CanvasPaintWin(view); | 420 return new CanvasPaintWin(view); |
| 419 #else | 421 #else |
| 420 return NULL; | 422 return NULL; |
| 421 #endif | 423 #endif |
| 422 } | 424 } |
| 423 | 425 |
| 424 } // namespace gfx | 426 } // namespace gfx |
| OLD | NEW |