blob: 5b9b75f562696045edaa9d81ae2c7bb4472a084e [file] [log] [blame]
daniel@transgaming.comb9d7e6f2012-10-31 19:08:32 +00001//
2// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
3// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5//
6
Jamie Madill135570a2014-09-30 16:33:51 -04007// Image.h: Implements the rx::Image class, an abstract base class for the
daniel@transgaming.com4ba24062012-12-20 20:54:24 +00008// renderer-specific classes which will define the interface to the underlying
9// surfaces or resources.
10
daniel@transgaming.comb9d7e6f2012-10-31 19:08:32 +000011#include "libGLESv2/renderer/Image.h"
Jamie Madill5a0c45e2014-10-02 11:10:36 -040012#include "libGLESv2/Framebuffer.h"
13#include "libGLESv2/main.h"
daniel@transgaming.comb9d7e6f2012-10-31 19:08:32 +000014
daniel@transgaming.com31b13e12012-11-28 19:34:30 +000015namespace rx
daniel@transgaming.comb9d7e6f2012-10-31 19:08:32 +000016{
daniel@transgaming.com0ad830b2012-10-31 19:52:12 +000017
daniel@transgaming.comb9d7e6f2012-10-31 19:08:32 +000018Image::Image()
19{
Jamie Madill135570a2014-09-30 16:33:51 -040020 mWidth = 0;
daniel@transgaming.comb9d7e6f2012-10-31 19:08:32 +000021 mHeight = 0;
shannon.woods%transgaming.com@gtempaccount.com4760c562013-04-13 03:42:30 +000022 mDepth = 0;
daniel@transgaming.comb9d7e6f2012-10-31 19:08:32 +000023 mInternalFormat = GL_NONE;
daniel@transgaming.com20d36662012-10-31 19:51:43 +000024 mActualFormat = GL_NONE;
shannon.woods%transgaming.com@gtempaccount.com56074f32013-04-13 03:45:30 +000025 mTarget = GL_NONE;
shannonwoods@chromium.org803be0a2013-05-30 00:08:59 +000026 mRenderable = false;
Geoff Lang34256ed2013-09-30 15:15:52 -040027 mDirty = false;
daniel@transgaming.comb9d7e6f2012-10-31 19:08:32 +000028}
29
Geoff Langef7b0162014-09-04 13:29:23 -040030gl::Error Image::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &area, gl::Framebuffer *source)
Jamie Madill5a0c45e2014-10-02 11:10:36 -040031{
32 gl::FramebufferAttachment *colorbuffer = source->getReadColorbuffer();
Geoff Langef7b0162014-09-04 13:29:23 -040033 ASSERT(colorbuffer);
Jamie Madill5a0c45e2014-10-02 11:10:36 -040034
Geoff Lang64f23f62014-09-10 14:40:12 -040035 RenderTarget *renderTarget = NULL;
36 gl::Error error = GetAttachmentRenderTarget(colorbuffer, &renderTarget);
37 if (error.isError())
38 {
39 return error;
40 }
41
Jamie Madill5a0c45e2014-10-02 11:10:36 -040042 ASSERT(renderTarget);
Geoff Langef7b0162014-09-04 13:29:23 -040043 return copy(xoffset, yoffset, zoffset, area, renderTarget);
Jamie Madill5a0c45e2014-10-02 11:10:36 -040044}
45
daniel@transgaming.comb9d7e6f2012-10-31 19:08:32 +000046}