| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "sky/engine/config.h" | 5 #include "sky/engine/config.h" |
| 6 #include "sky/engine/core/painting/CanvasImage.h" | 6 #include "sky/engine/core/painting/CanvasImage.h" |
| 7 | 7 |
| 8 namespace blink { | 8 namespace blink { |
| 9 | 9 |
| 10 CanvasImage::CanvasImage() : imageLoader_(adoptPtr(new NewImageLoader(this))) { | 10 CanvasImage::CanvasImage() { |
| 11 } | 11 } |
| 12 | 12 |
| 13 CanvasImage::~CanvasImage() { | 13 CanvasImage::~CanvasImage() { |
| 14 } | 14 } |
| 15 | 15 |
| 16 int CanvasImage::width() const { | 16 int CanvasImage::width() const { |
| 17 return bitmap_.width(); | 17 return bitmap_.width(); |
| 18 } | 18 } |
| 19 | 19 |
| 20 int CanvasImage::height() const { | 20 int CanvasImage::height() const { |
| 21 return bitmap_.height(); | 21 return bitmap_.height(); |
| 22 } | 22 } |
| 23 | 23 |
| 24 void CanvasImage::setSrc(const String& url) { | |
| 25 // TODO(jackson): Figure out how to determine the proper base URL here | |
| 26 KURL newSrcURL = KURL(KURL(), url); | |
| 27 if (srcURL_ != newSrcURL) { | |
| 28 srcURL_ = newSrcURL; | |
| 29 imageLoader_->Load(srcURL_); | |
| 30 } | |
| 31 } | |
| 32 | |
| 33 void CanvasImage::OnLoadFinished(const SkBitmap& result) { | |
| 34 // TODO(jackson): We'll eventually need a notification pathway for | |
| 35 // when the image load is complete so that we know to repaint, etc. | |
| 36 bitmap_ = result; | |
| 37 } | |
| 38 | |
| 39 } // namespace blink | 24 } // namespace blink |
| OLD | NEW |