Baby step in making SkGpuDevice no longer derive from SkBitmapDevice
https://codereview.chromium.org/23641008/
git-svn-id: http://skia.googlecode.com/svn/trunk@11311 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/include/core/SkDevice.h b/include/core/SkDevice.h
index 42624bf..ed1c8fd 100644
--- a/include/core/SkDevice.h
+++ b/include/core/SkDevice.h
@@ -85,7 +85,7 @@
*/
virtual void getGlobalBounds(SkIRect* bounds) const = 0;
- /** Returns true if the device's bitmap's config treats every pixels as
+ /** Returns true if the device's bitmap's config treats every pixel as
implicitly opaque.
*/
virtual bool isOpaque() const = 0;
@@ -332,7 +332,7 @@
int x, int y,
SkCanvas::Config8888 config8888) = 0;
- /** Called when this device is installed into a Canvas. Balanaced by a call
+ /** Called when this device is installed into a Canvas. Balanced by a call
to unlockPixels() when the device is removed from a Canvas.
*/
virtual void lockPixels() = 0;
diff --git a/include/gpu/SkGpuDevice.h b/include/gpu/SkGpuDevice.h
index 474fc2e..f80ef78 100644
--- a/include/gpu/SkGpuDevice.h
+++ b/include/gpu/SkGpuDevice.h
@@ -63,6 +63,21 @@
virtual GrRenderTarget* accessRenderTarget() SK_OVERRIDE;
// overrides from SkBaseDevice
+ virtual uint32_t getDeviceCapabilities() SK_OVERRIDE {
+ return 0;
+ }
+ virtual int width() const SK_OVERRIDE {
+ return NULL == fRenderTarget ? 0 : fRenderTarget->width();
+ }
+ virtual int height() const SK_OVERRIDE {
+ return NULL == fRenderTarget ? 0 : fRenderTarget->height();
+ }
+ virtual void getGlobalBounds(SkIRect* bounds) const SK_OVERRIDE;
+ virtual bool isOpaque() const SK_OVERRIDE {
+ return NULL == fRenderTarget ? false
+ : kRGB_565_GrPixelConfig == fRenderTarget->config();
+ }
+ virtual SkBitmap::Config config() const SK_OVERRIDE;
virtual void clear(SkColor color) SK_OVERRIDE;
virtual void writePixels(const SkBitmap& bitmap, int x, int y,
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index ea8a06e..a5c261c 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -569,6 +569,23 @@
}
///////////////////////////////////////////////////////////////////////////////
+void SkGpuDevice::getGlobalBounds(SkIRect* bounds) const {
+ if (NULL != bounds) {
+ const SkIPoint& origin = this->getOrigin();
+ bounds->setXYWH(origin.x(), origin.y(),
+ this->width(), this->height());
+ }
+}
+
+SkBitmap::Config SkGpuDevice::config() const {
+ if (NULL == fRenderTarget) {
+ return SkBitmap::kNo_Config;
+ }
+
+ bool isOpaque;
+ return grConfig2skConfig(fRenderTarget->config(), &isOpaque);
+}
+
void SkGpuDevice::clear(SkColor color) {
SkIRect rect = SkIRect::MakeWH(this->width(), this->height());
fContext->clear(&rect, SkColor2GrColor(color), fRenderTarget);
@@ -1554,7 +1571,7 @@
// drawDevice is defined to be in device coords.
CHECK_SHOULD_DRAW(draw, true);
- GrRenderTarget* devRT = device->accessRenderTarget();
+ GrRenderTarget* devRT = dev->accessRenderTarget();
GrTexture* devTex;
if (NULL == (devTex = devRT->asTexture())) {
return;