Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Side by Side Diff: ui/gfx/canvas.h

Issue 1424983005: ui: Fix NinePatchPainter to work in physical pixels. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ninepatchscale: testreview Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ui/gfx/canvas.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 float image_scale() const { return image_scale_; } 406 float image_scale() const { return image_scale_; }
410 407
411 private: 408 private:
412 // Test whether the provided rectangle intersects the current clip rect. 409 // Test whether the provided rectangle intersects the current clip rect.
413 bool IntersectsClipRectInt(int x, int y, int w, int h); 410 bool IntersectsClipRectInt(int x, int y, int w, int h);
414 bool IntersectsClipRect(const Rect& rect); 411 bool IntersectsClipRect(const Rect& rect);
415 412
416 // Helper for the DrawImageInt functions declared above. The |pixel| 413 // Helper for the DrawImageInt functions declared above. The |pixel|
417 // parameter if true indicates that the bounds and the image are to 414 // parameter if true indicates that the bounds and the image are to
418 // be assumed to be in pixels, i.e. no scaling needs to be performed. 415 // be assumed to be in pixels, i.e. no scaling needs to be performed.
419 void DrawImageIntHelper(const ImageSkia& image, 416 void DrawImageIntHelper(const ImageSkiaRep& image_rep,
420 int src_x, 417 int src_x,
421 int src_y, 418 int src_y,
422 int src_w, 419 int src_w,
423 int src_h, 420 int src_h,
424 int dest_x, 421 int dest_x,
425 int dest_y, 422 int dest_y,
426 int dest_w, 423 int dest_w,
427 int dest_h, 424 int dest_h,
428 bool filter, 425 bool filter,
429 const SkPaint& paint, 426 const SkPaint& paint,
430 float image_scale,
431 bool pixel); 427 bool pixel);
432 428
433 // The device scale factor at which drawing on this canvas occurs. 429 // The device scale factor at which drawing on this canvas occurs.
434 // An additional scale can be applied via Canvas::Scale(). However, 430 // An additional scale can be applied via Canvas::Scale(). However,
435 // Canvas::Scale() does not affect |image_scale_|. 431 // Canvas::Scale() does not affect |image_scale_|.
436 float image_scale_; 432 float image_scale_;
437 433
438 skia::RefPtr<skia::PlatformCanvas> owned_canvas_; 434 skia::RefPtr<skia::PlatformCanvas> owned_canvas_;
439 SkCanvas* canvas_; 435 SkCanvas* canvas_;
440 436
441 DISALLOW_COPY_AND_ASSIGN(Canvas); 437 DISALLOW_COPY_AND_ASSIGN(Canvas);
442 }; 438 };
443 439
444 } // namespace gfx 440 } // namespace gfx
445 441
446 #endif // UI_GFX_CANVAS_H_ 442 #endif // UI_GFX_CANVAS_H_
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/canvas.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698