Commit 79b65132 authored by danakj's avatar danakj Committed by Commit bot

content/aura: Use a PaintRecorder to access the Canvas for painting.

Don't use the canvas() from the PaintContext so that we can have the
PaintContext be backed by a DisplayItemList instead in the future.
Access to the Canvas should be done through a PaintRecorder.

R=piman@chromium.org, sadrul
BUG=466426

Review URL: https://codereview.chromium.org/1066183002

Cr-Commit-Position: refs/heads/master@{#324153}
parent 8ef99b8a
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include "ui/compositor/layer.h" #include "ui/compositor/layer.h"
#include "ui/compositor/layer_animation_observer.h" #include "ui/compositor/layer_animation_observer.h"
#include "ui/compositor/layer_delegate.h" #include "ui/compositor/layer_delegate.h"
#include "ui/compositor/paint_context.h" #include "ui/compositor/paint_recorder.h"
#include "ui/compositor/scoped_layer_animation_settings.h" #include "ui/compositor/scoped_layer_animation_settings.h"
#include "ui/gfx/animation/tween.h" #include "ui/gfx/animation/tween.h"
#include "ui/gfx/canvas.h" #include "ui/gfx/canvas.h"
...@@ -91,14 +91,13 @@ class ArrowLayerDelegate : public ui::LayerDelegate { ...@@ -91,14 +91,13 @@ class ArrowLayerDelegate : public ui::LayerDelegate {
paint.setStyle(SkPaint::kFill_Style); paint.setStyle(SkPaint::kFill_Style);
paint.setAntiAlias(true); paint.setAntiAlias(true);
gfx::Canvas* canvas = context.canvas(); ui::PaintRecorder recorder(context);
canvas->DrawCircle( recorder.canvas()->DrawCircle(
gfx::Point(left_arrow_ ? 0 : kArrowWidth, kArrowHeight / 2), gfx::Point(left_arrow_ ? 0 : kArrowWidth, kArrowHeight / 2),
kArrowWidth, kArrowWidth, paint);
paint); recorder.canvas()->DrawImageInt(
canvas->DrawImageInt(*image_.ToImageSkia(), *image_.ToImageSkia(), left_arrow_ ? 0 : kArrowWidth - image_.Width(),
left_arrow_ ? 0 : kArrowWidth - image_.Width(), (kArrowHeight - image_.Height()) / 2);
(kArrowHeight - image_.Height()) / 2);
} }
void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) override {} void OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) override {}
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include "ui/base/layout.h" #include "ui/base/layout.h"
#include "ui/compositor/layer.h" #include "ui/compositor/layer.h"
#include "ui/compositor/layer_animation_observer.h" #include "ui/compositor/layer_animation_observer.h"
#include "ui/compositor/paint_context.h" #include "ui/compositor/paint_recorder.h"
#include "ui/compositor/scoped_layer_animation_settings.h" #include "ui/compositor/scoped_layer_animation_settings.h"
#include "ui/gfx/canvas.h" #include "ui/gfx/canvas.h"
#include "ui/gfx/image/image_png_rep.h" #include "ui/gfx/image/image_png_rep.h"
...@@ -59,16 +59,16 @@ class ImageLayerDelegate : public ui::LayerDelegate { ...@@ -59,16 +59,16 @@ class ImageLayerDelegate : public ui::LayerDelegate {
private: private:
// Overridden from ui::LayerDelegate: // Overridden from ui::LayerDelegate:
void OnPaintLayer(const ui::PaintContext& context) override { void OnPaintLayer(const ui::PaintContext& context) override {
gfx::Canvas* canvas = context.canvas(); ui::PaintRecorder recorder(context);
if (image_.IsEmpty()) { if (image_.IsEmpty()) {
canvas->DrawColor(SK_ColorWHITE); recorder.canvas()->DrawColor(SK_ColorWHITE);
} else { } else {
SkISize size = canvas->sk_canvas()->getDeviceSize(); SkISize size = recorder.canvas()->sk_canvas()->getDeviceSize();
if (size.width() != image_size_.width() || if (size.width() != image_size_.width() ||
size.height() != image_size_.height()) { size.height() != image_size_.height()) {
canvas->DrawColor(SK_ColorWHITE); recorder.canvas()->DrawColor(SK_ColorWHITE);
} }
canvas->DrawImageInt(image_.AsImageSkia(), 0, 0); recorder.canvas()->DrawImageInt(image_.AsImageSkia(), 0, 0);
} }
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "third_party/skia/include/effects/SkGradientShader.h" #include "third_party/skia/include/effects/SkGradientShader.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/compositor/layer.h" #include "ui/compositor/layer.h"
#include "ui/compositor/paint_context.h" #include "ui/compositor/paint_recorder.h"
#include "ui/gfx/canvas.h" #include "ui/gfx/canvas.h"
#include "ui/gfx/skia_util.h" #include "ui/gfx/skia_util.h"
...@@ -49,7 +49,9 @@ void ShadowLayerDelegate::OnPaintLayer(const ui::PaintContext& context) { ...@@ -49,7 +49,9 @@ void ShadowLayerDelegate::OnPaintLayer(const ui::PaintContext& context) {
layer_->bounds().height()); layer_->bounds().height());
SkPaint paint; SkPaint paint;
paint.setShader(shader.get()); paint.setShader(shader.get());
context.canvas()->sk_canvas()->drawRect(gfx::RectToSkRect(paint_rect), paint); ui::PaintRecorder recorder(context);
recorder.canvas()->sk_canvas()->drawRect(gfx::RectToSkRect(paint_rect),
paint);
} }
void ShadowLayerDelegate::OnDelegatedFrameDamage( void ShadowLayerDelegate::OnDelegatedFrameDamage(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment