| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #ifndef UI_GFX_CANVAS_H_ | 5 #ifndef UI_GFX_CANVAS_H_ |
| 6 #define UI_GFX_CANVAS_H_ | 6 #define UI_GFX_CANVAS_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 int src_w, | 302 int src_w, |
| 303 int src_h, | 303 int src_h, |
| 304 int dest_x, | 304 int dest_x, |
| 305 int dest_y, | 305 int dest_y, |
| 306 int dest_w, | 306 int dest_w, |
| 307 int dest_h, | 307 int dest_h, |
| 308 bool filter, | 308 bool filter, |
| 309 const SkPaint& paint); | 309 const SkPaint& paint); |
| 310 | 310 |
| 311 // Same as the DrawImageInt functions above. Difference being this does not | 311 // Same as the DrawImageInt functions above. Difference being this does not |
| 312 // do any scaling, i.e. it assumes that the source/destination/image, etc are | 312 // do any scaling, i.e. it does not scale the output by the device scale |
| 313 // in pixels. It does translate the destination rectangle to ensure that the | 313 // factor (the internal image_scale_). It takes an ImageSkiaRep instead of |
| 314 // image is displayed at the correct pixel coordinates. | 314 // an ImageSkia as the caller chooses the exact scale/pixel representation to |
| 315 void DrawImageIntInPixel(const ImageSkia& image, | 315 // use, which will not be scaled while drawing it into the canvas. |
| 316 int src_x, | 316 void DrawImageIntInPixel(const ImageSkiaRep& image_rep, |
| 317 int src_y, | |
| 318 int src_w, | |
| 319 int src_h, | |
| 320 int dest_x, | 317 int dest_x, |
| 321 int dest_y, | 318 int dest_y, |
| 322 int dest_w, | 319 int dest_w, |
| 323 int dest_h, | 320 int dest_h, |
| 324 bool filter, | 321 bool filter, |
| 325 const SkPaint& paint); | 322 const SkPaint& paint); |
| 326 | 323 |
| 327 // Draws an |image| with the top left corner at |x| and |y|, clipped to | 324 // Draws an |image| with the top left corner at |x| and |y|, clipped to |
| 328 // |path|. | 325 // |path|. |
| 329 // Parameters are specified relative to current canvas scale not in pixels. | 326 // Parameters are specified relative to current canvas scale not in pixels. |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 float image_scale() const { return image_scale_; } | 414 float image_scale() const { return image_scale_; } |
| 418 | 415 |
| 419 private: | 416 private: |
| 420 // Test whether the provided rectangle intersects the current clip rect. | 417 // Test whether the provided rectangle intersects the current clip rect. |
| 421 bool IntersectsClipRectInt(int x, int y, int w, int h); | 418 bool IntersectsClipRectInt(int x, int y, int w, int h); |
| 422 bool IntersectsClipRect(const Rect& rect); | 419 bool IntersectsClipRect(const Rect& rect); |
| 423 | 420 |
| 424 // Helper for the DrawImageInt functions declared above. The |pixel| | 421 // Helper for the DrawImageInt functions declared above. The |pixel| |
| 425 // parameter if true indicates that the bounds and the image are to | 422 // parameter if true indicates that the bounds and the image are to |
| 426 // be assumed to be in pixels, i.e. no scaling needs to be performed. | 423 // be assumed to be in pixels, i.e. no scaling needs to be performed. |
| 427 void DrawImageIntHelper(const ImageSkia& image, | 424 void DrawImageIntHelper(const ImageSkiaRep& image_rep, |
| 428 int src_x, | 425 int src_x, |
| 429 int src_y, | 426 int src_y, |
| 430 int src_w, | 427 int src_w, |
| 431 int src_h, | 428 int src_h, |
| 432 int dest_x, | 429 int dest_x, |
| 433 int dest_y, | 430 int dest_y, |
| 434 int dest_w, | 431 int dest_w, |
| 435 int dest_h, | 432 int dest_h, |
| 436 bool filter, | 433 bool filter, |
| 437 const SkPaint& paint, | 434 const SkPaint& paint, |
| 438 float image_scale, | |
| 439 bool pixel); | 435 bool pixel); |
| 440 | 436 |
| 441 // The device scale factor at which drawing on this canvas occurs. | 437 // The device scale factor at which drawing on this canvas occurs. |
| 442 // An additional scale can be applied via Canvas::Scale(). However, | 438 // An additional scale can be applied via Canvas::Scale(). However, |
| 443 // Canvas::Scale() does not affect |image_scale_|. | 439 // Canvas::Scale() does not affect |image_scale_|. |
| 444 float image_scale_; | 440 float image_scale_; |
| 445 | 441 |
| 446 skia::RefPtr<skia::PlatformCanvas> owned_canvas_; | 442 skia::RefPtr<skia::PlatformCanvas> owned_canvas_; |
| 447 SkCanvas* canvas_; | 443 SkCanvas* canvas_; |
| 448 | 444 |
| 449 DISALLOW_COPY_AND_ASSIGN(Canvas); | 445 DISALLOW_COPY_AND_ASSIGN(Canvas); |
| 450 }; | 446 }; |
| 451 | 447 |
| 452 } // namespace gfx | 448 } // namespace gfx |
| 453 | 449 |
| 454 #endif // UI_GFX_CANVAS_H_ | 450 #endif // UI_GFX_CANVAS_H_ |
| OLD | NEW |