From 873cb1e23b64e4b2d11749352b626bcef204bdd7 Mon Sep 17 00:00:00 2001 From: "reed@google.com" Date: Thu, 23 Dec 2010 15:00:45 +0000 Subject: add gpu to the default makefile move skia-gpu files into skia/src/gpu git-svn-id: http://skia.googlecode.com/svn/trunk@653 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/gpu/SkGpuCanvas.cpp | 60 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/gpu/SkGpuCanvas.cpp (limited to 'src/gpu/SkGpuCanvas.cpp') diff --git a/src/gpu/SkGpuCanvas.cpp b/src/gpu/SkGpuCanvas.cpp new file mode 100644 index 0000000000..19bda4d943 --- /dev/null +++ b/src/gpu/SkGpuCanvas.cpp @@ -0,0 +1,60 @@ +/* + Copyright 2010 Google Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + + +#include "GrContext.h" + +#include "SkGpuCanvas.h" +#include "SkGpuDevice.h" + +/////////////////////////////////////////////////////////////////////////////// + +SkGpuCanvas::SkGpuCanvas(GrContext* context) { + SkASSERT(context); + fContext = context; + fContext->ref(); +} + +SkGpuCanvas::~SkGpuCanvas() { + // call this now, while our override of restore() is in effect + this->restoreToCount(1); + fContext->flush(false); + fContext->unref(); +} + +/////////////////////////////////////////////////////////////////////////////// + +bool SkGpuCanvas::getViewport(SkIPoint* size) const { + if (size) { + SkDevice* device = this->getDevice(); + if (device) { + size->set(device->width(), device->height()); + } else { + size->set(0, 0); + } + } + return true; +} + +SkDevice* SkGpuCanvas::createDevice(SkBitmap::Config config, int width, int height, + bool isOpaque, bool isLayer) { + SkBitmap bm; + bm.setConfig(config, width, height); + bm.setIsOpaque(isOpaque); + return new SkGpuDevice(this, bm, isLayer); +} + + -- cgit v1.2.3